Home >Web Front-end >Front-end Q&A >How to set img to flip horizontally in css3
In CSS3, you can use the Transform attribute to set the horizontal flip of the img element. The Transform attribute is used to set the 2D or 3D transformation of the element. The rotateY() method is used to set the 3D rotation of the element along the Y axis. The syntax "Picture Element {transform:rotateY(angle value);}".
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
In css, you can rotate the image 180 degrees on the Y axis to flip the image
The example is as follows:
Create a new html file, named test.html, to explain how CSS can flip images.
Use the img tag to create an image for testing. Set the class attribute of the img tag to mypic.
In the css tag, set the style of the image through the class attribute. Then use the transform attribute to rotate the image 180 degrees on the Y axis through rotateY, thereby flipping the image.
Open the test.html file in the browser to check the effect.
Summary:
1. Use the img tag to create a picture and set the class attribute of the img tag to mypic.
2. In the css tag, set the style of the image through the class attribute.
3. In the css tag, use the transform attribute to rotate the image 180 degrees on the Y axis through rotateY, thereby flipping the image.
4. Open the test.html file in the browser to check the effect.
(Learning video sharing: css video tutorial)
The above is the detailed content of How to set img to flip horizontally in css3. For more information, please follow other related articles on the PHP Chinese website!