.custom-section
.block.-left
img.background(src='https://habrastorage.org/webt/bh/2j/xs/bh2jxssdtpgm4kpnxup20cwthvc.jpeg')
a.link(href='') Summer
.block.-right
img.background(src='https://habrastorage.org/webt/hw/in/11/hwin11royv18333vmg8e_ucsmju.jpeg')
a.link(href='') Winter
View Compiled
@import url('https://fonts.googleapis.com/css?family=Sawarabi+Mincho');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-family: 'Sawarabi Mincho', sans-serif;
}
body {
background: #302015;
background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23BA8E59' fill-opacity='.1' fill-rule='evenodd'/%3E%3C/svg%3E");
}
.custom-section {
position: relative;
width: 95%;
margin: 2rem auto;
height: 20rem;
max-height: 95vh;
border-radius: .2rem;
overflow: hidden;
box-shadow: 0 0 1rem rgba(0, 0, 0, .3);
> .block {
position: absolute;
width: 60%;
height: inherit;
overflow: hidden;
}
> .block.-left {
left: 0;
transform: skew(-15deg) translate(-15%);
}
> .block.-right {
right: 0;
transform: skew(-15deg) translate(15%);
border-left: 5px solid #FFFAFF;
}
> .block > .background {
position: absolute;
height: 100%;
width: 100%;
object-fit: cover;
font-family: 'object-fit: cover;'
}
> .block.-left > .background {
transform: skew(15deg) translateX(15%);
}
> .block.-right > .background {
transform: skew(15deg) translateX(-15%);
}
> .block > .link {
position: absolute;
top: 50%;
width: 60%;
text-align: center;
line-height: 2rem;
text-decoration: none;
color: #302015;
padding: 0 1rem;
text-transform: uppercase;
background: rgba(255, 255, 255, .9);
transition: all 180ms cubic-bezier(.5, 0, .5, 1);
transform: skew(15deg) translateY(-50%);
box-shadow: 0 0 1rem rgba(0, 0, 0, .3);
&:hover,
&:focus {
background: rgba(0, 0, 0, .8);
color: #FFFFFF;
outline: none;
}
}
> .block.-left > .link {
right: 0;
border-radius: .2rem 0 0 .2rem;
}
> .block.-right > .link {
left: 0;
border-radius: 0 .2rem .2rem 0;
}
}
@media screen and (max-width: 30rem) {
.custom-section {
> .block {
position: relative;
width: 100%;
height: 50%;
}
> .block.-left,
> .block.-right {
transform: none;
border: none;
}
> .block.-left > .background,
> .block.-right > .background {
transform: none;
}
> .block.-left > .link,
> .block.-right > .link {
left: 50%;
right: auto;
transform: translateX(-50%) translateY(-50%);
border-radius: .2rem;
}
}
}
View Compiled
document.addEventListener('DOMContentLoaded', () => {
// https://cdnjs.cloudflare.com/ajax/libs/object-fit-images/3.2.3/ofi.min.js
objectFitImages(); // IE & Edge 12-15 don't support object-fit
});
View Compiled
This Pen doesn't use any external CSS resources.