Home > Web Front-end > Front-end Q&A > How to set img to flip horizontally in css3

How to set img to flip horizontally in css3

WBOY
Release: 2022-04-20 18:10:30
Original
5598 people have browsed it

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);}".

How to set img to flip horizontally in css3

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

How to set img horizontal flip in css3

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.

How to set img to flip horizontally in css3

Open the test.html file in the browser to check the effect.

How to set img to flip horizontally in css3

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!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template