I am experimenting with rotating a div on hover and then extending its right side with a slanted angle. So far, I have successfully extended the div on hover.
div{
height: 200px;
width: 200px;
background-color:wheat;
transition: .2s;
margin-top: 1em;
margin-left: 10em;
margin-bottom: 10em;
overflow: hidden;
}
div:after{
-webkit-transition: .2s;
transition: .2s;
content: '';
position: absolute;
top: 0;
left: 25%;
width: 0px;
height: 200px;
background: wheat;
overflow: hidden;
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
-webkit-transform: skew(-35deg);
transform: skew(-35deg);
z-index: -1;
margin-left: 10em;
margin-top: 1em;
}
div:hover:after {
-webkit-transition: .2s;
transition: .2s;
width: 200px;
height: 200px;
background: wheat;
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
-webkit-transform: skew(-35deg);
transform: skew(-35deg);
z-index: -1;
margin-top: 1em;
margin-left: 10em;
margin-bottom: 10em;
}
<div>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Similique dicta adipisci qui fugit, eum eaque dolorem accusamus natus animi nam, deleniti tempora fugiat iusto minima optio commodi laudantium veritatis quos.</p>
</div>
However, when attempting to rotate the main div using transform: rotate(-45deg);
, the following pseudo element does not function as expected. Are there any solutions for this issue, or perhaps a JavaScript alternative that could simplify the process?