Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of centering DIV CSS fixed width

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this "DIV CSS fixed width center method" article, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "DIV CSS fixed width center method" article.

The degree of DIV is in the middle, and the crux of the problem is to use the word CSS as margin:0 auto.

Explanation: the outer margin of the DIV object is dominated by automatically adapting to the isolation distance (according to the object setting the equipment setting width, actively arbitrarily setting the device width and setting the equipment width, the remaining width is manipulated actively to achieve the center of the structure), and the high-down spacing is 0px.

Crux example CSS code:

Body {text-align:center} .box {margin:0 auto; width:500px; height:100px; border:1px solid # 00F}

First of all, the body setting equipment setting a css mode center, of course, in order to be compatible with the major readers acquiesced in the mode for the center of the initial setting equipment equipment, how to center the selector setting construction center (margin:0 auto), fixed width setting equipment for 500px, height 100px 1px CSS frame for the solid blue frame.

Here, the 500px width is configured arbitrarily, and in the practical organization, according to the requirements, in order to see the DIV being centered, exit the height and border to get a glimpse of the attainments of the fixed width centered instance.

The complete HTML code of the instance:

DIVCSSS5 instance body {text-align:center} .box {margin:0 auto; width:500px; height:80px; border:1px solid # 00F} CSS5 rest width centered instance

Screenshot of achievement of an example

The above is about the content of this article on "the method of DIV CSS fixed width centering". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report