How to scale div elements with css

WBOY
Release: 2021-11-29 17:42:44
Original
8767 people have browsed it

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

How to scale div elements with css

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>
Copy after login

Output result:

How to scale div elements with css

(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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!