Ragmah Ragmah - 1 month ago 4
CSS Question

Skew property applying to paragraph

I am using skew but the transformation is also applying to all the content inside the skewed box as you can see in my pen. The paragraph is looking italicized.
http://codepen.io/Sidney-Dev/pen/RGXVpb



.services {
display: flex;
overflow: hidden;
}
.left {
background-color: black;
height: 250px;
width: 60%;
margin-left: -50px;
}
.right {
background-color: green;
width: 50%;
margin-right: -500px
}
.skew {
transform: skew(-15deg);
}
p {
color: white;
}

<section class="services">
<div class="left skew">
<div class="inner-container">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro praesentium deserunt fugiat, qui est delectus vel eligendi totam quidem amet laudantium harum, saepe voluptates voluptatibus. Aliquam ea, totam nulla magni.</p>
</div>
</div>
<div class="right skew">
</div>
</section>





How can I skew the box without affecting the content inside?

Hope you can help

Answer

You skewed by -15deg. Just add 15deg to your .inner-container like this:

.skew .inner-container {
  transform: skew(15deg);
}

to "unskew" only the inner content.

.services {
  display: flex;
  overflow: hidden;
}
.left {
  background-color: black;
  height: 250px;
  width: 60%;
  margin-left: -50px;
}
.right {
  background-color: green;
  width: 50%;
  margin-right: -500px
}
.skew {
  transform: skew(-15deg);
}
.skew .inner-container {
  transform: skew(15deg);
}
p {
  color: white;
}
<section class="services">
  <div class="left skew">
    <div class="inner-container">
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro praesentium deserunt fugiat, qui est delectus vel eligendi totam quidem amet laudantium harum, saepe voluptates voluptatibus. Aliquam ea, totam nulla magni.</p>
    </div>
  </div>
  <div class="right skew">
  </div>
</section>

Comments