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 the main content area of HTML not on the left but horizontally

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

Share

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

This article mainly introduces the "HTML main content area does not rely on the left but the horizontal center method", in the daily operation, I believe that many people in the HTML main content area does not rely on the left but the horizontal center method question, the editor consulted all kinds of data, sorted out the simple and easy to use operation method, hope to answer the "HTML main content area does not rely on the left but the horizontal center method" the doubt is helpful! Next, please follow the editor to study!

The whole page is not centered, but on the left. The cause of the title problem is that the outermost layer is not equipped with the center of the organization, and some set up float:left, so that the whole page is left rather than centered.

First, the planned use of floating causes the html to be out of the center.

The outermost DIV uses float:left (center) or float:right (right), which constitutes a good solution that the whole html cannot be centered. Remove the outermost layer using float, plus margin:0 auto is compatible with major browsers, and then the whole page changes to center in a second.

Using float causes the html page to be left, not centered.

Control the outermost DIV center, complete the whole html center

Clarify: the page should be centered, so the outermost DIV box object can not use the float property, while configuring margin:0 auto to complete the entire html center, and the form of DIV can use float floating will not affect the page center. The key to the hub is to set up the outermost equipment in the middle.

Second, configure the CSS organization to be centered and be compatible with each other.

The outermost layer of the original uses float:left to cause the entire page to be on the left. If there is no floating float here, the whole page will be in the middle of some hunters, and some on the left. At this time, it is easier, only to set the outermost DIV equipment to install margin:0 auto.

Complete the HTML center illustration diagram

At this point, the study on the "HTML main content area does not rely on the left but the horizontal center method" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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