CSS Advanced Essentials Notes

Source: Internet
Author: User

CSS Advanced

* Snap To block elements

Text-align:center can be used for horizontal alignment of content within a block element;

You can use the margin property for the alignment of the block elements themselves in the layout, and you can align them horizontally by setting the left and right margins to auto.

<!DOCTYPE HTML><HTML><Head><style>. Center{margin:Auto;width:70%;Background-color:#b0e0e6;}</style></Head><Body><Divclass= "Center"><P>This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</P><P>This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</P></Div><P><b>Comments:</b>Unless it's been declared! DOCTYPE, otherwise the use of Margin:auto is not valid in IE8 and earlier versions.</P></Body></HTML>

It is important to note that unless it has been declared! DOCTYPE, otherwise Margin:auto is invalid in IE8 and earlier versions.

You can also set the left and right alignment by using the Position property.

<!DOCTYPE HTML><HTML><Head><style>. Center{position:Absolute; Right:0;width:70%;Background-color:#b0e0e6;}</style></Head><Body><Divclass= "Center"><P>This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</P><P>This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</P></Div></Body></HTML>

You can also use float to set up:

<!DOCTYPE HTML><HTML><Head><style>. Right{float: Right;width:300px;Background-color:#b0e0e6;}</style></Head><Body><Divclass= "Right"><P>This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</P><P>This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</P></Div></Body></HTML>

CSS Advanced Essentials Notes

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.