CSS width width property
The CSS width property is used to control the width of web page elements. The width can accept automatic judgment width (auto), custom width percentage (%) or inherited from the parent layer wi dth property value, CSS width property can be used in DIV Blocks , span areas, images ( img tags ), text input fields ( textarea ), buttons ( button )... and many other web page elements are designed for width, and are supported by all major browsers. The CSS width property is often used to Use the height attribute to design the height of web page elements .
CSS width width attribute syntax
Width value | grammar | Description |
auto | width:auto; | Automatically determine the width of web page elements. |
length | width: number + unit; | Acceptable units are px, em, cm and other web standard units. |
% | width: number%; | Use percentages to set the width of web page elements, you need a reference for comparison. |
inherit | width:inherit; | The width attribute value inherited from the parent layer. |
CSS width example of width property 1. Set image width
<img src="upload/20141007145509.png" style="width:auto;"><br><br>
Set the image width to 100px<br>
<img src="upload/20141007145509 .png" style="width:100px;"><br><br>
Set the image width to 50%<br>
<img src="upload/20141007145509.png" style="width:50%;">< br>

set the image width to 100px and

the image width to 50%

- HTML img image tag
- HTML img width Image width
<div style="border:1px black solid; width:400px; ">The width of this DIV is 400px</div> div>
The scope of application of the CSS width property is very wide. In addition to directly using the width property to design the width of web page elements, web designers can also use higher-level min-width , max-width and other advanced properties to limit The minimum and maximum width limits of web page elements.
Post a Comment
0 Comments