I wanted to mirror letter E
in the word WEBLOG
so I used CSS transform property but it doesn't work if I wrap the text inside a span but it works if I assing display: inline-block;
or display: block;
So transforms doesn't apply to inline elements?
Example 1 (Fails To Transform)
<h1>W<span>E</span>BLOG</h1> h1 span { transform:rotate(7deg); -ms-transform:rotate(7deg); /* IE 9 */ -moz-transform:rotate(7deg); /* Firefox */ -webkit-transform:rotate(7deg); /* Safari and Chrome */ -o-transform:rotate(7deg); /* Opera */ }
Example 2 (Works, If Used display: block
OR display: inline-block
)
CSS transform doesn't work on inline elements.
The transform CSS property lets you rotate, scale, skew, or translate an element.
Inline element properties: The height of an inline element is the height of the content. The width of an inline element is the width of the content. The height and width of an inline element cannot be set in CSS.
An inline element will not accept height and width. It will just ignore it. So the height and width that you have entered in css will be ignored that is why the empty div is not visible. moreover try using inline-block, it will solve the issue.
Answered here in the official W3 specifications under transformable element:
an element whose layout is governed by the CSS box model which is either a block-level or atomic inline-level element, or whose ‘display’ property computes to ‘table-row’, ‘table-row-group’, ‘table-header-group’, ‘table-footer-group’, ‘table-cell’, or ‘table-caption’ [CSS21]
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