Home > Web Front-end > HTML Tutorial > Parse the difference between width:100%; and width:auto;

Parse the difference between width:100%; and width:auto;

巴扎黑
Release: 2017-03-14 11:30:10
Original
2215 people have browsed it

<p>
    <p>1111</p>
</p>
p{
  width:980px;<br>  background-color: #ccc;<br>  height:300px;
}
p{
     width:100%;<br>  /*width:auto;*/
    padding:10px;<br>  background-color:#000;<br>
}
Copy after login



If the width of p is: 100%, it means that the width of p will be 980px, which will fill the p area, and then there is padding, so it will exceed p.

And when width:auto, it is the overall width (including width, margin, padding, border) equal to the parent width (width, excluding parent margin, padding, border), so if padding has taken up 10px of space on the left and right, then the value given by width is 960px.

But whether it is width:100% or auto, the calculation reference is the parent content area width value, not the total width value.

The above is the detailed content of Parse the difference between width:100%; and width:auto;. For more information, please follow other related articles on the PHP Chinese website!

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