In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to achieve the center of layout and content in css". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
I. the center of acquaintance structure and form
1. CSS DIV layout is centered
The layout is centered on the frame box itself. To center the web page body horizontally in the browser, you need to configure margin:0 auto to complete the construction center.
The layout is centered on the frame box itself.
The center of the organ is mainly to set up the equipment for the structural frame, such as the DIV box. Usually the outermost body frame in the web page layout is set up in the agency centered format (margin:0 auto). Suppose you do not set the equipment center code, some readers are centered, but some hunters are shown on the left, causing compatibility problems, so you must configure a margin:0 auto style to center a box horizontally in the reader.
Commonness: the completion of the center is quite extraordinarily completed using margin patterns, which requires rated attention.
2. CSS DIV mode is in the middle.
With the DIV organization center has the same form of center word center, it is in the box mode (calligraphy, pictures, etc.) to achieve the level of center. Use CSS fancy words and the value code is text-align:center. Whether it is the div tag, H2 tag, h3 tag, p tag and other html element tag settings can make it to cope with the degree of form in the box.
Expand the CSS code:
CSS content is centered: text-align:center
CSS form to the left: text-align:left
CSS content to the right: text-align:right
Second, distinguish between the two qualities.
CSS construction is centered: the frame configuration is centered (for example, the DIV level of DIV's own equipment is centered in the browser).
The CSS form is centered: the setting degree of the form in the box is centered (for example, the DIV is put into pictures, text, etc.)
Third, apply the goal
The CSS structure is centered to complete the main body level is centered in the browser; the CSS mode is centered to complete the content in the frame box. In terms of DIV layout, the former is in the middle of configuring the DIV framework box itself, while the latter is in the middle of the content contained in DIV.
Fourth, it is easy to center the case of picture and text.
1. The structure is in the middle
In order to see the effectiveness of the structure center, we configure a DIV with a width of 300pxposition CSS high 100pxash CSS frame in red and set the equipment layout centering code margin:0 auto
1), complete DIV CSS code
Simple agency instance CSS5.CSS5 {margin:0 auto; width:300px; height:100px; border:1px solid # F00} structure is easy to center
2) screenshot of the effectiveness of the agency in the middle
2, form Center in order to examine the effect of centered, left and right content, we set up three div boxes with the same width of 300px; the frame of 100px high is red, and the parting setting is centered, right and left.
1), incomplete HTML code (DIV CSS code)
An example of easy content centralization and organizational centralization: CSS5.CSS5 {margin:0 auto;width:300px;height:100px;border:1px solid # F00 text centralization; agency centralization and pattern centralization simple examples
You can center the contents of the box by adding text-align:center.
2) screenshot of the effectiveness of centered content
This is the end of the content of "how to center the layout and content of css". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.