Want to let Div center, how to write CSS?

Source: Internet
Author: User
Css

Page Layout Technique example, want to let Div center, how to write CSS?

Div-Centered settings How do I write css? We are in the traditional table layout, as long as the table to set the center property to achieve the center of the block element. Application div CSS site layout, Div center How to write CSS to control it?

The main style definitions are as follows:

body {text-align:center;}
#center {margin-right:auto; margin-left:auto;}

First, the parent element defines text-align:center, which means that the content within the parent element is centered;

For IE this setting is already OK. But you can't center in Mozilla. The solution is to add margin-right:auto when the child element definition is set; Margin-left:auto;

Need special instructions, please note in the layout, if you want to use this method to make the whole page to center, we suggest not to set up in a Div, you can split out multiple div, as long as in each of the div defined margin-right:auto; Margin-left:auto, that's all.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.