I was trying to skew a div but not its content regardless of whether it is image or text which should be vertical.
I have gone through many of the question related to my error on stack like
Create a slanted edge to a div,
How to skew element but keep text normal (unskewed)
In my aspect, nothing seems to help.
I have placed the image on to the left and text on to the right both of them should be skewed. but when I flip them like placing an image on to the right and (vice versa), it should justify itself.
Here is an inspirational image.
and here is a Fiddle I've worked for it.
<div class="container">
<div class="partial-section">
<div class="section-inner">
<div id="parallelogram">
<div class="image"></div>
</div>
</div>
</div>
<div class="partial-section">
<h1> This is some heading on the right partial section.</h1>
<p>Some random text that should be appeared on the right side of the partial section. This should be below the heading the partial section has and should fill the empty space that it has.</p>
</div>
</div>
body {
margin: 0;
padding: 0;
font-family: Arial;
}
* {
box-sizing: border-box;
}
.container {
max-width: 1160px;
margin: 0 auto;
background-color: green;
height: 450px;
}
.partial-section {
width: 50%;
background-color: red;
height: inherit;
display: inline;
float: left;
border: 2px solid lightgrey;
padding: 20px;
}
.partial-section h1 {
font-size: 40px;
}
.partial-section p {
font-size: 20px;
}
.section-inner {
height: inherit;
}
#parallelogram {
width: 100%;
height: inherit;
transform: skew(-40deg);
position: relative;
top: 0;
overflow: hidden;
}
.image {
background: url(http://placekitten.com/601/301);
background-size: cover;
position: absolute;
top: 0;
background-repeat: no-repeat;
-webkit-transform: skew(-20deg);
-moz-transform: skew(-20deg);
-o-transform: skew(-20deg);
height: inherit;
width: 100%;
transform: skew(40deg);
}
It would be a great pleasure if someone could help me out with this.
Thanks in advance.