How to realize the animation effect of panorama in CSS3
This article mainly shows you "how to achieve the animation effect of panorama in CSS3". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn "how to achieve the animation effect of panorama in CSS3".
Html Code:
First define some basic styles and animations:
.panorama {
Width:300px
Height:300px
Background-image:url (http://7vilbi.com1.z0.glb.clouddn.com/blog/6608185829213862083.jpg);
Background-size:auto100%
Cursor:pointer
Animation:panorama10slinearinfinitealternate
}
@ keyframespanorama {
To {
Background-position:100%0
}
}
The background-size:auto100%; code means that the image is higher than the container, and the horizontal direction is automatic, that is, the leftmost side of the picture is attached to the left side of the container.
The process of performing animation is: cycle, alternation, linearity, and time period is 10s.
Manually control animation execution
Now we let the mouse move when it hovers over the picture, and let it rest when the mouse leaves.
You need to use this attribute animation-play-state:paused | running, which represents the two states of the animation: pause and run.
Complete CSS code:
.panorama {
Width:300px
Height:300px
Background-image:url (http://7vilbi.com1.z0.glb.clouddn.com/blog/6608185829213862083.jpg);
Background-size:auto100%
Cursor:pointer
Animation:panorama10slinearinfinitealternate
Animation-play-state:paused
}
.panorama: hover
.panorama: focus {
Animation-play-state:running
}
@ keyframespanorama {
To {
Background-position:100%0
}
}
The above is all the content of the article "how to achieve the animation effect of panorama in CSS3". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!