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

How to use css to set centering

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to use css to set up the center, the article introduces in great detail, has a certain reference value, interested friends must read it!

In a page constructed by DIV CSS, it is very important to center the text in black and white, from the form of the organ to the center of the text in the page, and it is also easy to configure css in the middle.

1. Introduction to the use of css attributes to make the overall organization center:

The parent form of the configuration object is centered. What is the parent of a page here? We may imagine that the form of the entire page is covered by these two. According to the nearest parent, we set the CSS of the equipment body to complete the centering problem. The centering code that can center the text-align:center; specific css in the form is as follows:

Body {text-aligh:center } however, even this will show the title, because you do not configure how wide the agency is, once you configure the float: attribute in the outermost css constraint in your formal construction, the organization will set the float to you: lean, planning method, in addition to configuring the central css property of the body, you also need to configure the agency object in the center, not to mention what the width is, if the width of the page is 700px. The outermost css pattern is class= "weicheng", that setting should be how ".weicheng {margin:0 auto" Width:700px;} "and this element is valid under IE. Through the experiment, except for the body setting, text-aligh:center; centering is impossible to center the layout under hunting devices such as Firefox, so we also need to configure a" margin:0 auto "for this object. "what does this mean? it means that the isolation distance between the top and bottom of the mode is 0, and the left and right is" auto "enthusiastically. How can you set up equipment to achieve the center of the web page structure (setting margin:5px auto; abnormal results here does not affect the experiment). The complete example is (you can copy the code to create a new html file to dabble in the bystander effect):

An example of centering the structure of css5.com.cn 's CSS div

I am the central executive in css; my organ has a black edge with a 1px outside, I am wide 700px, high is 200px, and the isolation distance from the top mode is set to 5PX

CSS Organization Center example browsing

2. Use the css attribute to center the setting of the web page: here the center includes the center and the high and low center, and the center code is as follows: body {BACKGROUND: # FFF url (/ / www.css5.com.cn/img/css-logo.gif) no-repeat center } / / the implication of this paragraph is to make the css-logo.gif image configuration setting not repeated (no-repeat), and the center (center) is dominated by the center, while the vertical does not need to be equipped with equipment, and the positive will be centered.

3. Css: let the introduction of calligraphy and the content of the picture center around. Tutorial: we know that it is easy to manipulate, directly use text-align:center;, that is, outline to make the pen and ink center with the picture form, but vertical, if we are vertically centered at the height of 120px, the picture is centered on vertical-align:middle. Css attribute, the pen and ink center depends on setting the line height method to center the calligraphy mode, here we set the equipment to set the height of the 120px which needs to set a line-height:120px; how through the css attribute class format to achieve the height of the pen and ink and pictures around the center. The code centered on the entire site is as follows:

An example of the broken center of css5.com.cn 's CSS div

I am a broken central instance in css; my layout has an outer edge called 1px

图片内容居中

The above is all the content of the article "how to use css to set the center". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow 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