<div class="wrap">
<div class="head">上の要素</div>
<div class="main">斜め背景の要素<br>どのブラウザ幅でも上下の要素と被らない</div>
<div class="foot">下の要素</div>
</div>
.wrap {
overflow: hidden;
}
.head {
background: gray;
padding: 50px 0;
text-align: center;
}
.foot{
background: gray;
padding: 50px 0;
text-align: center;
}
.main {
text-align:center;
color: white;
padding: 100px 0;
margin: calc(100vw * 0.08748866352 / 2) 0;
position: relative;
border-top: 1px solid red;
border-bottom: 1px solid red;
&:before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: black;
transform: skewY(5deg);
z-index: -1;
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.