In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-05 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 "div centralization and div content centralization". 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!
First, div himself is in the middle:
Apply margin:0 auto
The concave and convex is 0, which dominates the self-adaptive css pattern.
In order to keep the div level in the middle, you can't set the equipment float in addition to configuring css margin:0 auto, otherwise it will cause div to the left (set float:left) and div to the right (configure float:right).
1. Div structure centered example code
Div Organization Center instance CSS5#jz {margin:0 auto; width:320px; height:100px; border:1px solid # F00} configure margin:0 auto compatible readers to center div horizontally
2. Screenshot
Screenshot of div box leveling centered
The above example is the use of margin:0 auto to make div compatible with each major reader level in the middle.
2. The content in the div is centered:
The model is divided equally into the middle of the div model and the vertical center of the div model.
Div content horizontal center compared to the construction of div center, and div form center comparison is simple, only need to configure a form center css (text-align:center), form vertical center (line-height).
1. The formal level of div is in the middle. CSS:
Text-align:center
No matter whether it is div as usual, or set up equipment for it, the CSS implementation is in the middle of the mode level in the corresponding response image.
2. Vertical center line height attribute of div content:
Line-height
To center vertically in the form of only one line within the div, the div mode can be vertically centered by usually communicating between the height (height) and the line-height (line height) of the div configuration.
3. Example code of horizontal and vertical centering of div content
Div centered instances CSS5#juzhong {width:320px;height:100px; line-height:100px; text-align:center; border:1px solid # F00} text-align and line-height configurations are centered horizontally and vertically
4. Screenshot
An example of vertical centering layout between div formal leveling and div mode
From the image above, we can see that the div content is in the middle between the two conditions, but the equipment is not set margin:0 auto and the div is not centered.
You can copy the above code again under the example, and try to achieve the center of the DIV layout code to achieve the center of DIV.
This is the end of the content of "div centralization and div content centralization". Thank you for 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.