Home  >  Article  >  Web Front-end  >  How to stretch pictures in css style

How to stretch pictures in css style

WBOY
WBOYOriginal
2021-12-03 15:52:017206browse

In CSS, you can use the transform attribute to stretch the image. When the value of this attribute is "scale()", you can stretch the image element. You only need to add "transform" to the image element. :scale(horizontal stretch ratio, vertical stretch ratio);" style is enough.

How to stretch pictures in css style

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

How to stretch images in css style

In css, you can use the transform attribute to stretch the image. The function of the transform attribute is to Elements are rotated, scaled, moved, or tilted.

When the value of the attribute is scale(), the image can be stretched.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    .img2{
        transform:scalex(2);
    }
    .img3{
        transform:scalex(3);
    }
    </style>
</head>
<body>
    <img  src="1118.02.png" class="img1" alt="How to stretch pictures in css style" ><br>
    <img  src="1118.02.png" class="img2" alt="How to stretch pictures in css style" ><br>
    <img  src="1118.02.png" class="img3" alt="How to stretch pictures in css style" ><br>
</body>
</html>

Output result:

How to stretch pictures in css style

(Learning video sharing: css video tutorial)

The above is the detailed content of How to stretch pictures in css style. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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