In CSS, you can use the width and height attributes to change the height and width of an image. You only need to add the "width: width value; height: height value;" style to the image element. The width attribute sets the width of the element, and the height attribute sets the height of the element.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In CSS, you can use the width and height attributes to change the height and width of an image.
The width attribute can set the width of the element, and the height attribute can set the height of the element.
Example:
<!DOCTYPE html> <html> <head> <style> .img1 { width: 400px; height: 400px; } </style> </head> <body> <p>原图片宽度:200px,高度:200px</p> <img src="img/1.jpg" alt="How to change the height and width of an image with css" > <p>使用css设置宽度为:400px,高度为:400px</p> <img class="img1" src="img/1.jpg" alt="How to change the height and width of an image with css" > </body> </html>
(Learning video sharing: css video tutorial)
The above is the detailed content of How to change the height and width of an image with css. For more information, please follow other related articles on the PHP Chinese website!