css layout study notes max-width_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:07:54
Original
1884 people have browsed it

Setting the width of a block-level element prevents it from filling the container from left to right. Then you can set the left and right margins to auto to center it horizontally. The element will occupy the width you specify, and then the remaining width will be divided into two left and right margins.

div{  width: 600px;  margin: 0 auto; }
Copy after login

The only problem is that when the browser window is narrower than the width of the element, the browser displays a horizontal scroll bar to accommodate the page.

Using max-width instead of width in this case allows the browser to handle small window situations better.

div {  max-width: 600px;  margin: 0 auto; }
Copy after login

This knowledge point is very simple, but I think it is very important, so I will record it~

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