Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSS3 – RotateY() in center

I wanna rotateY() but from center of this earth image. Now it’s rotating from the right side. Here is my code:

@keyframes rotate {
    to {
        transform: rotateY(-360deg);
    }
}

http://jsfiddle.net/qwrg9684/

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It works if you operate on the image directly. https://jsfiddle.net/akso4r6q/

<img id="logo" src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Erioll_world_2.svg/256px-Erioll_world_2.svg.png" />
#logo {
    animation: rotate 5s linear infinite;
    transform-origin: center center;
}

@keyframes rotate {
    to {
        transform: rotateY(360deg);
    }
}

If you need it to be in a div you can also set display: inline-block;. The appearance of rotating around the right side of the image is actually the rotation happening around the center of the enclosing div which is expanding horizontally to fit the viewport.

You can see a fiddle here that shows this with a text element that is a sibling of the image.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading