html - CSS3 布局 - 4 列多边形

标签 html css

我的 View 中的 4 列布局有一个大问题。

我必须构建这个布局:

http://oi68.tinypic.com/2ntz6gg.jpg

有人知道我如何制作这个布局吗?我使用 -clip 方法,但第一个 div 总是来自最后一个 div。两个居中的 div 可以,但 first 和 last 不行。

如果你知道我该怎么做,请帮助我......

最佳答案

下面是一个结合定位使用梯形边框的例子:

body {
  margin: 0;
}
.section {
  position: relative;
  display: inline-block;
  width: 25%;
  margin-right: -4px;
}
.background {
  position: absolute;
  top: 0;
  width: 100%;
  height: 0;
  border-right: 30px solid transparent;
  border-bottom: 300px solid #346;
}
.content {
  position: absolute;
  top: 0;
  color: #fff;
  padding: 10px 10px 10px 30px;
  z-index: 100;
}
.s1 .background {
  border-bottom-color: yellow;
  z-index: 5;
}
.s2 .background {
  border-bottom-color: blue;
  z-index: 4;
}
.s3 .background {
  border-bottom-color: navy;
  z-index: 3;
}
.s4 .background {
  background-color: black;
  border: none;
  height: 300px;
}
<div class="section s1">
  <div class="background"></div>
  <div class="content">Lorem Ipsum</div>
</div>
<div class="section s2">
  <div class="background"></div>
  <div class="content">Lorem Ipsum</div>
</div>
<div class="section s3">
  <div class="background"></div>
  <div class="content">Lorem Ipsum</div>
</div>
<div class="section s4 last">
  <div class="background"></div>
  <div class="content">Lorem Ipsum</div>
</div>

限制:您必须定义固定高度(上例中的300px)

关于html - CSS3 布局 - 4 列多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38827360/

相关文章:

html - 使用媒体查询消除样式加载

html - URL 框架打破了响应式网站

javascript - 仅为 View 中的元素添加类

css - 重写 material-ui 样式

html - 如何在整个网站上显示背景图片

html - 电子邮件设计 : resizing text for mobile removes mobile image swap

javascript - 如何获取子 div 的值

html - 如何仅使用 CSS 设置 <select> 下拉菜单的样式?

html - 图片不显示使用 css

javascript - 总和未正确计算