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 make div center in div in CSS

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 the relevant knowledge of "how to make div center in CSS". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to make div center in div in CSS" can help you solve the problem.

The div layout is centered, that is, the outermost div is centered, and css adopts margin:0 auto without setting float.

Here, let div be centered in div, the practical way and principle are mutually exclusive, the important central div can set margin:0 atuo (just do not configure float) to achieve the center of div in div.

1. Instance code

Div centered instance in div css5.com.cn#main {width:400px; float:left; padding:10px 0; border:1px solid # 090} .ctbox {margin:0 auto; width:300px; border:1px solid # 00F} I am the blue div in the green div, centered

An example shows:

1) the above code is roughly copied directly from the theory of use

2), the above right div (id=main) is arranged with a div to complete the center (class=ctbox). In order to see that the div within the div is centered, the width and border pattern are configured.

This is the end of the introduction on "how to center div in CSS in div". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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