I'm trying to create this nav menu (green highlight is the active page, gray is hover state):
I can make the parallelogram with the following CSS:
ul#nav li a {
text-decoration:none;
padding:4px 10px;
border-radius:3px;
transform: skew(-10deg);
-o-transform: skew(-10deg);
-moz-transform: skew(-10deg);
-webkit-transform: skew(-10deg);
color:#757575;
}
ul#nav li a:hover {
background:#f3f1eb;
}
ul#nav li a.current-menu-item {
color:#fff;
background:#5d9732;
}
ul#nav li a.current-menu-item:hover {
background:#5d9732;
}
Unfortunately, this causes the text to skew as well, appearing italic:
Here's a jsfiddle showing the setup (although the skew doesn't work in jsfiddle): http://jsfiddle.net/K3bQJ/4/
Is there any way to prevent the skew of the text, so it doesn't appear italic? I'm loading jQuery but would prefer to avoid it or at least have a usable CSS fallback.
Thanks for any advice!
Try this Add a span inside your tags and set it's skew to the opposite direction (note the use of skewX which is considered correct according to https://developer.mozilla.org/en/CSS/-moz-transform)
<ul id="nav">
<li><a class="current-menu-item" href="#"><span>Nav Item 1</span></a></li>
<li><a href="#"><span>Nav Item 2</span></a></li>
<li><a href="#"><span>Nav Item 3</span></a></li>
</ul>
ul#nav li a {
display: inline-block;
text-decoration:none;
padding:4px 10px;
border-radius:3px;
transform: skewX(-10deg);
-o-transform: skewX(-10deg);
-moz-transform: skewX(-10deg);
-webkit-transform: skewX(-10deg);
color:#757575;
}
ul#nav li a span {
display: inline-block;
transform: skewX(10deg);
-o-transform: skewX(10deg);
-moz-transform: skewX(10deg);
-webkit-transform: skewX(10deg);
}
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