Convert inline elements to different points of block elements using float and display:block

Source: Internet
Author: User

Use float and display:block to convert inline elements to different points of block elements:
recommendation : As far as possible handwriting code, can effectively improve the learning efficiency and depth.
Inline elements can be converted to block-level elements, such as the use of the float property for inline elements to float inline elements, or to add displayto inline elements: block. Although both can make inline elements into block-level elements, there are differences. The code example is as follows:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Ant Tribe</title><styletype= "Text/css">a{Height:30px;Line-height:30px;float: Left;Background-color:#F60;}</style></Head><Body>  <ahref="#">Ant Tribe</a></Body></HTML>

The above code uses float to achieve the conversion of a element to block-level elements, you can see that the width is based on the content. Let's look at a code example:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Ant Tribe</title><styletype= "Text/css">a{Height:30px;Line-height:30px;Display:Block;Background-color:#F60;}</style></Head><Body>  <ahref="#">Ant Tribe</a></Body></HTML>

The above code adds display:block to the a element and converts it to an accounting element, but the width is not determined by the content, but by default it is width:100%.
There may be more differences between the two, welcome to add a message.

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=4615

For more information, refer to: http://www.softwhy.com/divcss/

Convert inline elements to different points of block elements using float and display:block

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.