HTML Introduction to HTML and CSS Make It Beautiful With CSS Select and Style Multiple Elements by Class

Ben Sohl
Ben Sohl
4,462 Points

I am trying to copy the code used in the example where the profile photo turns onto my own page.

I am trying to copy the code used in the example where the profile photo turns onto my own page. The code is literally copied and pasted, but I changed the class to match mine. The photo is expanding, but it won't rotate. Here's what I have:

HTML:

<img src="ProfilePic.jpg" class="pic">

CSS:

.pic:hover { transform: scale(1.4) rotate(360deg);}

Any ideas? Thanks!

1 Answer

Flor Antara
Flor Antara
12,355 Points

Hi Ben,

Your code is fine. What happens is that you are not being able to see the rotation effect, because it's set to rotate 360 degrees, meaning that it will end up being in its initial place.

Try another value, like (45deg) for instance.

Also, if you want it to animate while it rotates so you can actually see the effect even if it's going to end up in the same position, you can add a transition to the selector:

.pic{
    transition: transform 1s linear;
}

^ This transitions the transform property.