html - 溢出 :hidden making hidden the pseudo element itself

标签 html css

<分区>

我正在尝试使用上曲线的伪元素来实现下面的布局,但是这样做有问题

enter image description here

我试过了

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/

上一篇:html - 删除点击按钮周围的边框

下一篇:javascript - 在 JavaScript 中格式化使用数组生成的表

相关文章:

html - 图片前的文字

javascript - 如何在 Javascript 中选择多个类而不是 id

html - 具有 100% 宽度的响应式表格

javascript - 完全响应式 HTML5 视频

javascript - Mobile Safari 和 x-offset

php - 我怎样才能提取某些 HTML 标签,例如<ul> 在 PHP 中将正则表达式与 preg_match_all 结合使用?

jquery - 在 jquery 中显示/隐藏相同的按钮

javascript - 可接受的动画帧率是多少?

html - CSS - 网页上的多个图像交叉淡入淡出

javascript - jQuery 错误 "Unexpected token ILLEGAL"中的反斜杠