css - 矩形 div css
问题描述
我想使用矩形背景,如下图的红色部分。我该怎么做?
我想使用类似的背景
#trapezium {
height: 0;
width: 50vw;
border-bottom: 100vh solid #ec3504;
border-left: 60px solid transparent;
}
解决方案
您将需要使用linear-background,也许是这样的:
.testBG
{
width: 100vw;
height: 100vh;
background: linear-gradient(115deg, #aaaaaa 50%, red 50%);
}
<div class="testBG"></div>
在接下来的示例中,色标(百分比)不等于只是为了模拟颜色之间的平滑过渡,并且角度也发生了变化:
.testBG
{
width: 100vw;
height: 100vh;
background: linear-gradient(100deg, #aaaaaa 50%, red 51%);
}
<div class="testBG"></div>
.testBG
{
width: 100vw;
height: 100vh;
background: linear-gradient(125deg, #aaaaaa 50%, red 80%);
}
<div class="testBG"></div>
推荐阅读
- angular - 无法绑定指令
- ckeditor - 从 Office 插件粘贴不去除字体颜色
- node.js - 需要升级 docx-wasm node js
- javascript - 页面重定向后,activeClassName 在反应路由器 NavLink 中不起作用
- javascript - 是否可以在 HTML 页面中添加指令来阻止或限制 JavaScript?
- java - 为什么 System.out.println(3+(4-3)/2); 在 java 中打印 3 但不是 2 但 System.out.println(4/2) 正确打印 2
- python - 可以考虑在 Python 中用作逻辑值的列表不会转换为 True/False 吗?
- angular - Swagger codgen:如何在 swagger codgen 中添加附加属性
- java - 如何通过 viber/whatsapp 从 java 发送消息
- c++ - C++ 错误:表达式必须具有 Bool 类型