Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a rotation point for an element in CSS?

Is it possible to set the rotation point in CSS? The default rotation point is at the 50%, 50%. I tried:

transform: rotate(230deg);  rotation-point:90% 90%; 

But it does not work... Any suggestions?

like image 523
kugyousha Avatar asked Jul 11 '11 15:07

kugyousha


People also ask

How do you rotate an element in CSS?

The CSS rotate() function lets you rotate an element on a 2D axis. The rotate() function accepts one argument: the angle at which you want to rotate your web element. You can rotate an element clockwise or counter-clockwise.

How do I rotate an image with a point in CSS?

You could use transform-origin. It defines the point to rotate around from the upper left corner of the element. This would rotate around the upper left corner.

What is the CSS property for rotating an HTML element?

The transform property applies a 2D or 3D transformation to an element. This property allows you to rotate, scale, move, skew, etc., elements.


2 Answers

This will set the rotation pivot point on top-left corner of your element and rotate it:

transform: rotate(-25deg); transform-origin: 0% 0%; 

take a glance at .nav_item_txt class:

http://jsfiddle.net/KHkX7/

like image 109
Marco Allori Avatar answered Nov 08 '22 20:11

Marco Allori


Use the transform-origin CSS property:

.class {     transform-origin: 0 0; } 
like image 26
spraff Avatar answered Nov 08 '22 20:11

spraff