I’ve created a button for my website with a CSS class and I wanted it to have a parallelogram shape so I’ve used the skew function to create the shape. The code was right and the button has the shape that I wanted but the text inside the button resulted skewed as well following its wrap. There’s a way to make the text not looking like the Leaning Tower inside my button?
Here’s the html code:
<input type="submit" alt="submit" value="Login" class="button">
And that’s the CSS for the button class:
.button {
float: top;
width: 275px;
height: 40px;
margin-top: 6px;
display: inline-block;
font-family: Impact;
text-align: center;
-webkit-transform: skewX(20deg);
-moz-transform: skewX(20deg);
-o-transform: skewX(20deg);
transform: skewX(20deg);
}
Partly seconding Sidharth, I think you won’t get around the wrapper element to apply the CSS-transform on and then reset it for its child elements (the submit-input):
Sidharth’s answer implies that you completely hide the original
<input>and relies on JavaScript to trigger a click on it when the styled wrapper is clicked, but here’s and easy way around that: Style thebutton-wrapperon:hoverand remove all styles from the nested<input>-element and make it 100% wide (jsBin example):