html - 3个带有倾斜边的div
问题描述
我正在尝试创建一个并排有 3 个 div 的布局,流体大小(我将分别处理小屏幕尺寸),其中内侧是倾斜的。它应该是这样的:
|_/_/_| or |_/_\_|
两者都可以。我尝试了以下方法,但我认为这不是正确的解决方案。
.holder .mainSelection {
display: flex;
overflow: hidden;
width: 100%;
height: 200px;
border: 2px solid black;
}
.mainSelection .box {
height: 100%;
transform: skew(15deg);
position: relative;
}
.mainSelection .box:nth-child(1) {
background: #F40C42;
margin-left: -30px;
flex: 0 0 33%;
}
.mainSelection .box:nth-child(2) {
background: #DBF408;
flex: 0 0 34%;
border-left: 2px solid black;
border-right: 2px solid black;
}
.mainSelection .box:nth-child(3) {
background: #58F40B;
flex: 0 0 33%;
}
.mainSelection .box:nth-child(3):after {
content: "";
position: absolute;
width: 100px;
height: 100%;
background: #58F40B;
-webkit-transform: skewX(-15deg);
right: -50px;
}
上面代码的问题是第三个 div 比前两个大。
任何人都可以提出更好的解决方案吗?
解决方案
推荐阅读
- java - 从两个列表的组合中形成新的小列表
- javascript - HTML5 Geolocation API 在 Firefox 中不起作用
- c++ - 释放 COM 指针的异常
- sql-server - Transact-SQL:使用表 2 中的可选连接属性连接两个表
- c++ - 如何通过引用传递opencv mat
- java - Android 适配器进入构造函数但未创建 ListView
- android - Flutter 应用程序未运行仅显示“等待另一个 Flutter 命令释放启动锁”
- c# - 起订量和设置不返回值
- php - “函数”或“闭包”类型的 php 类型提示
- javascript - 修复了缩放时 svg 圆形元素的半径