Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the picture size of img by css

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "css how to set the picture size of img", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "css how to set the picture size of img" bar!

In css, you can use the width and height attributes to set the size of the img element picture, the width attribute to set the width value of the element, and the height attribute to set the height value of the element. The syntax is "img element {width: width value; height: height value;}".

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

How to set the picture size of img with css

In css, you can use the width and height properties to set the image size of img, as shown in the following example:

123 .tupian {width:150px; height:150px;}

The size is set above, but not below.

Output result:

In the above example, both the width and height properties are set, and to achieve proportional scaling, you only need to set one property. Examples are as follows:

When adding only width:150px; styles, output the result:

When adding only height:150px; styles, output the result:

Thank you for reading, the above is the content of "css how to set the picture size of img". After the study of this article, I believe you have a deeper understanding of how css sets the picture size of img. The specific use also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report