JSFiddle - React, Tailwind, and code Playground
Skew box exploration
by mzilverberg
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css">
<div class="c-box">
<figure class="c-box__figure">
<div class="c-box__img">
<img src="https://picsum.photos/480/320/?gravity=east" />
</div>
</figure>
<div class="c-box__text">
<h2>
Lorem ipsum dolor sit amet
</h2>
<p>
Maecenas faucibus mollis interdum. Maecenas sed diam eget risus varius blandit sit amet non magna. Nullam quis risus eget urna mollis ornare vel eu leo.
</p>
</div>
</div>
SCSS
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,400i,800i');
@mixin sizing($sizing: border-box) {
-webkit-box-sizing: $sizing;
-moz-box-sizing: $sizing;
box-sizing: $sizing;
}
@mixin skewX($deg) {
transform: skewX($deg);
}
* {
&,
&:before,
&:after {
@include sizing();
}
}
html { padding: 2em; overflow: scroll; }
h2 {
font: 900 33px/1.09 "Open Sans", sans-serif;
font-style: italic;
text-transform: uppercase;
margin-top: 0;
}
.c-box {
display: flex;
flex-direction: row;
align-items: stretch;
align-content: flex-start;
position: relative;
background: #000;
color: #fff;
margin-bottom: 18px;
&:before {
display: block;
content: "";
position: absolute;
bottom: 0;
right: 0;
left: 0;
height: 18px;
background: #1f1f1f;
}
&__figure,
&__text {
/**/
}
&__figure {
display: flex;
align-items: stretch;
width: 50%;
margin: -18px 0 0;
vertical-align: top;
background: #fff;
overflow: hidden;
position: relative;
z-index: 1;
@media (min-width: 544px) {
max-width: 80%;
}
}
&__img {
position: relative;
padding-bottom: 18px;
& img {
display: block;
height: 100%;
}
&:before {
display: block;
position: absolute;
content: "";
top: 0;
right: -23%;
bottom: 0;
width: 75%;
background: #000;
border-top: 18px solid #fff;
border-bottom: 18px solid #1f1f1f;
z-index: 1;
@include skewX(-15deg);
}
}
&__text {
position: relative;
z-index: 2;
width: 100%;
padding: 24px;
font: 16px/1.4 Arial, sans-serif;
@media (min-width: 544px) {
padding: 42px;
}
@media (min-width: 768px) {
padding: 54px 84px;
}
}
}