In CSS, you can use the transform attribute to scale div elements. When the value of this attribute is "scale(x,y)", you can scale the element. The syntax is "transform:scale( Horizontal scaling ratio, vertical scaling ratio);".
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
How to scale div elements in css
We can scale div elements through the transform attribute. When the value of the transform attribute is set to "scale(x,y)" means that we can perform 2D scaling transformation on the div element.
Let’s take an example to see how to scale the div. The example is as follows:
<!DOCTYPE html> <html> <head> <style> .no{ width:300px; height:100px; background-color:#ff9900; } .yes{ width:300px; height:100px; background-color:#ff9900; transform:scale(0.5,0.5); } </style> </head> <body> <p>没缩放的div元素:</p> <div class="no"></div> <p>缩放的div元素:</p> <div class="yes"></div> </body> </html>
Output result:
(Learning video Share: css video tutorial)
The above is the detailed content of How to scale div elements with css. For more information, please follow other related articles on the PHP Chinese website!