Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS transform doesn't work on inline elements

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)

like image 438
Mr. Alien Avatar asked Feb 14 '13 20:02

Mr. Alien


People also ask

Does transform work on inline elements?

CSS transform doesn't work on inline elements.

Which elements can be transformed CSS?

The transform CSS property lets you rotate, scale, skew, or translate an element.

Can we change width of inline elements?

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.

Why my display inline not working?

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.


1 Answers

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]

like image 110
Giacomo1968 Avatar answered Sep 18 '22 13:09

Giacomo1968