<分区>
<分区>
我正在尝试使用上曲线的伪元素来实现下面的布局,但是这样做有问题
我试过了
ul li{
width: 300px;
min-height: 400px;
border: 5px solid #bcbcbc;
padding: 5px;
list-style: none;
}
.upper{
height: 200px;
}
.bottom{
background: #000;
height: 200px;
position: relative;
overflow: hidden;
}
.bottom:before
{
content: '';
position: absolute;
top:-50px;
border-bottom:25px solid #000;
content: '';
position: absolute;
top: -50px;
border-bottom: 25px solid #000;
border-top: 25px solid transparent;
width: 100%;
border-left: 150px solid transparent;
border-right: 150px solid #000;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul>
<li>
<div class="upper"></div>
<div class="bottom"></div>
</li>
</ul>
</body>
</html>
但是当我为 .bottom
类 overflow hidden 时,它隐藏了伪元素本身。请指出我哪里做错了
最佳答案
你可以在没有 pseudo
元素的情况下使用 skew()
方法做到这一点:
ul li{
width: 300px;
height:400px ;
border: 5px solid #bcbcbc;
padding: 5px;
list-style: none;
}
.parent{
overflow:hidden;
position:relative;
height:100%;
width:100;
}
.bottom{
background: #000;
height: 400px;
width:100%;
position:absolute;
bottom:-200px;
left:0;
transform:skewY(-15deg)
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul>
<li>
<div class="parent">
<div class="bottom"></div>
</div>
</li>
</ul>
</body>
</html>
关于html - 溢出 :hidden making hidden the pseudo element itself,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57176621/