The difference between CSS width: 100% and width: auto_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:42:26
Original
892 people have browsed it

The difference between width: 100% and width: auto

width: auto is smarter. If the margin has taken up 10px of space on the left and right, then the value given by width is 580px.

<style>div{width:600px;overflow:auto;background:#ccc;}p{        width:auto;        margin:10px;        background:red;}</style></head><body><div>    <p>123</p></div></body></html>
Copy after login

If width:100%, it means p The width will be 600px, which will fill the div area, and then it will have margin, so a scroll bar will appear.

div{width:600px;overflow:auto;background:#ccc;}p{        width:100%;        margin:10px;        background:red;}</style></head><body><div>    <p>123</p></div>
Copy after login

are all based on the width of the parent element.

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