Diagonal Section Separators v2
Source:
https://codepen.io/ahmadnassri/pen/bByOKv
by Corey Donovan
HTML
<div class="image above">
<section>
<header></header>
<div class="separator"></div>
<footer></footer>
</section>
</div>
CSS
:root {
--width: 100%;
--height: 100px;
--top-color: #f44336;
--bottom-color: #f8fcff;
}
body {
background-color: #fff;
margin: 0px;
}
.separator {
position: relative;
width: var(--width);
height: var(--height);
}
.separator::before {
position: absolute;
content: "";
width: 100%;
height: 100%;
background-color: var(--top-color);
clip-path: polygon(100% 0, 0 0, 100% 100%);
}
.separator::after {
position: absolute;
content: "";
width: 100%;
height: 100%;
background-color: var(--bottom-color);
clip-path: polygon(0 0, 0 100%, 100% 100%);
}
section {
}
section header {
background: var(--top-color);
}
section footer {
background: var(--bottom-color);
}
section header,
section footer {
height: var(--height);
}
.image.above section header {
height: calc(var(--height) * 2);
background-image: linear-gradient(-45deg, rgba(2,0,36,1) 0%, rgba(9,9,121,1) 35%, rgba(0,212,255,1) 100%);
background-size: cover;
background-position: bottom;
}
.image section {
position: relative;
}
.image .separator {
position: absolute;
}
.image.above .separator {
--top-color: transparent;
margin-top: calc(var(--height) * -1);
}