Is it possible to reproduce this image using only CSS?
I want to apply this to my menu, so the brown background appears on hover
instance
I don't know how to do this, I only have;
.menu li a:hover{ display:block; background:#1a0000; padding:6px 4px; }
NOTE: SPAN is NOT affected by transform CSS functionality, so you will need a DIV or change span to display: block; otherwise they will NOT be affected. So just put the TEXT inside a separate div and unskew it. Show activity on this post. You can generate your clip from here and use it in your code.
CSS | skew() Function ax: This parameter holds the angle representing the horizontal axis to distort an element. ay: This parameter holds the angle representing the vertical axis to distort an element. If it is not defined then it takes the default value zero. It means completely skew in x direction.
Syntax. The skew() function is specified with either one or two values, which represent the amount of skewing to be applied in each direction. If you only specify one value it is used for the x-axis and there will be no skewing on the y-axis.
Try this: To unskew the image use a nested div for the image and give it the opposite skew value. So if you had 20deg on the parent then you can give the nested (image) div a skew value of -20deg. @darthmaim's answer (below) to use a psuedo (before or after) to skew the inner border's should be the accepted answer.
skew
a parent element (LI
) and inverse skew it's children elements
nav ul { padding: 0; display: flex; list-style: none; } nav li { transition: background 0.3s, color 0.3s; transform: skew(20deg); /* SKEW */ } nav li a { display: block; /* block or inline-block is needed */ text-decoration: none; padding: 5px 10px; font: 30px/1 sans-serif; transform: skew(-20deg); /* UNSKEW */ color: inherit; } nav li.active, nav li:hover { background: #000; color: #fff; }
<nav> <ul> <li><a href="#">Home</a></li> <li class="active"><a href="#">Products</a></li> <li><a href="#">Contact</a></li> </ul> </nav>
Here is a fiddle for use across different browsers - I created in a couple of minutes.
Try playing with the arguments, I used :before
and :after
to do this.
https://jsfiddle.net/DTBAE/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With