Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a rotated image in CSS?

Tags:

html

css

I have written below code. But now the requirement is that the image should be rotated 180 degrees. How can I achieve this?

#cell { background-image: url("../images/logo.PNG");  background-attachment: fixed;  background-repeat: no-repeat; background-position: 0px 250px; background-color: #FFFFFF; border-left: 2px; } 

HTML tag:

    <td width="2%" id="cell"/> 
like image 337
user968880 Avatar asked Jan 20 '12 09:01

user968880


People also ask

How do I rotate an image 90 degrees CSS?

We can add the following to a particular tag in CSS: -webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -o-transform: rotate(90deg); -ms-transform: rotate(90deg); transform: rotate(90deg); In case of half rotation change 90 to 45 .

How do you make an image rotate in HTML?

Syntax: transform: rotate(90deg);


1 Answers

One cross-browser solution is

#cell {   -webkit-transform: rotate(180deg);     /* Chrome and other webkit browsers */   -moz-transform: rotate(180deg);        /* FF */   -o-transform: rotate(180deg);          /* Opera */   -ms-transform: rotate(180deg);         /* IE9 */   transform: rotate(180deg);             /* W3C compliant browsers */    /* IE8 and below */   filter: progid:DXImageTransform.Microsoft.Matrix(M11=-1, M12=0, M21=0, M22=-1, DX=0, DY=0, SizingMethod='auto expand'); }  

Note, that for IE8 and below, the rotation center point is not located in the center of the image (as it happens with all other browsers). So, for IE8 and below, you need to play with negative margins (or paddings) to shift the image up and left.

The element needs to be blocked. Other units that can be used are: 180deg = .5turn = 3.14159rad = 200grad

like image 88
Jose Rui Santos Avatar answered Sep 30 '22 22:09

Jose Rui Santos