0

I'm trying to make transition stuff by -25 degrees but what i want is to only transit "box", not the font. The thing that i don't understand is how to make it with :before/:after. Whenever i try to do it via CSS it basically ignores all setting i've made for specific container.

.option:hover
{
font-style: normal !important;
background-color: green;
cursor: pointer;
box-sizing: border-box;
transition-property: background;
transition-duration: .4s;
left: 0;
top: 0;
-webkit-transform: skew(-25deg);
}

http://jsfiddle.net/3fndahd2/

1 Answer 1

1

The thing is that you skew the whole div, which includes anything inside. There's no way to exclude anything.

There are two ways around this:

  1. Apply the opposite skew to inner elements, i.e. have an additional container for the text which is skewed the other way around in order to be straight again. I wouldn't do this, because it may lead to a blurry result or artifacts.
  2. Use CSS3 pseudo-elements: Create an element using ::before, give it full parent size and skew this one. It's outside your text, so that's not affected by the transform. In addition, use z-index to place it behind the parent div. JSFiddle
1
  • Really helpful, gonna try to use both of this options, edit and combine some additional setups to see how it works and analyse mostly behaviour of :before/:after functions! Thanks once again :)
    – nehel
    Commented Apr 1, 2015 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.