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 realize the centering of background picture and text content by css

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

Share

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

This article mainly explains the "css how to achieve the background picture center and text content center", the text explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "css how to achieve background picture center and text content center" bar!

On the DIV CSS page, it is very important to center the text in black and white, from the form of organization to the center of the article on the page, and it is also very easy to set up the center of css.

1. First of all, introduce the use of the css attribute to center the group structure:

The parent form of the configuration object is centered. What is the parent of a page here? We may imagine that the mode of the entire page is collected by and these two, then in accordance with the closer parent, we configure body's CSS to complete the center title, or the center code with text-align:center; specific css in the mode is:

Body {text-aligh:center } but even if there is a problem, because you have not set how wide the layout is "width", once you configure the float: attribute in the outermost css control in your pattern construction, the structure will lean on the float: direction you set, and fix it. In addition to setting the css property of the equipment body in the center, you also need to center the organization object, or define the width, if the width of the page is 700px. The outermost css style is class= "weicheng", that setting should be how ".weicheng {margin:0 auto" Width:700px;} "is fine, and this element is valid under IE. Through experiments, under hunting devices such as Firefox, except for this body setting, text-aligh:center; cannot center the structure, so we also need to configure a" margin:0 auto "for this object. "what does this mean? the meaning is that the mode bump is 0 partition, and the manipulation is" auto "active, so that you can set the completion of the web page to center (here the configuration of margin:5px auto; also does not affect performance). The complete example is (you can copy the code to create a new html file to dabble in observation hesitation attainments):

An example of the construction of CSS div in css5.com.cn I am a central experiment in css; my mechanism has an outer edge with a 1px color edge, I am wide 700px, and the height is 200px, and is configured to partition from the top mode to 5PX.

CSS structure centered instance browsing

2. Introduce the application of the css attribute to center the scene of the web page: here the center includes the left and right center and the bump center, and the center code is as follows: body {BACKGROUND: # FFF url (/ / www.css5.com.cn/img/css-logo.gif) no-repeat center } / / the meaning of this paragraph is to let the css-logo.gif picture set the equipment backup does not repeat (no-repeat), and center (center) this is to dominate the center, while the vertical does not need to set the equipment, will automatically center.

3. Css let the introduction pen and ink, picture content high and low center tutorial: we know that the left and right side is easy to do, directly use text-align:center;, that is, probably let the pen and ink and the picture content center, but vertical, if we in the height of the height of 120px vertical center, the picture center is vertical-align:middle Css attribute, the pen and ink center depends on setting the line height to center the pen and ink content. Here we configure the height of the 120px, which requires setting a line-height:120px; to complete the high and low control of the text and the picture through the css attribute class style. The code in the center of the entire site is as follows:

Css5.com.cn 's incomplete centered instance of CSS div I am a complete centered instance in css; my layout has an outer edge of 1px

图片内容居中

Thank you for your reading, the above is the "css how to achieve the background picture center and text content center" content, after the study of this article, I believe you on how to achieve css background picture center and text content center this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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