width: auto
width: 100%
An example is worth a thousand words: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> * { margin: 0;padding: 0; } body { background: #dcdcdc; } .box { width: 400px; border: 3px solid red; padding: 0 50px; } .box1 { width: auto; height: 100px; background: pink; padding: 0 50px; margin: 0 50px; border-width: 0 50px; border-style: solid; border-color: green; } .box2 { width: 100%; height: 100px; background: gold; padding: 0 50px; margin: 0 50px; border-width: 0 50px; border-style: solid; border-color: green; } .box3 { width: 100px;height: 100px;background: orange; } .box4 { float: left; width: 50px;height: 50px;background: pink; } </style> </head> <body> <div class="box"> <div class="box1"></div> <div class="box2"></div> </div> </body> </html> Note: Image sub-width is changed to sub-content This is the end of this article about the detailed explanation of the difference between the default values of the CSS attribute width, width: auto and width: 100%. For more relevant content about CSS width: auto and width: 100%, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. We hope that everyone will support 123WORDPRESS.COM in the future! |
<<: How to migrate the data directory in Docker
>>: Setting z-index property for flash overlay popup layer in web design does not work
When the created tab label exceeds the visible ar...
Solution: Kill all .vscode related processes in t...
This article shares the specific code of js to ac...
Table of contents 1. Direct assignment 2. Shallow...
When using MySQL to run certain statements, a dea...
Table of contents Props comparison of class compo...
Abstract: This article mainly explains how to ins...
1 / Copy the web project files directly to the we...
How to check the file system type of a partition ...
The main part of the page: <body> <ul id...
<br /> The website access speed can directly...
Table of contents 1. Scenario Description 2. Solu...
1. What is ElasticSearch? Elasticsearch is also d...
Why is NULL so often used? (1) Java's null Nu...
It has been a long time since the last update of ...