CSSdiv width adaptive

Source: Internet
Author: User
In practical applications, there may be such a need, that is, the div needs to be adaptive Based on the width of the content. Many developers may mistakenly think that width can be adaptive with content without setting the div width, because by default, the div width is, that is, the width of the entire parent element is occupied. The code example is as follows:


  
  Code Nong tutorial

Codenong course welcomes you

The code above shows that by default, we cannot achieve the desired effect. The following code is modified:


  
  Code Nong tutorial

Codenong course welcomes you

The above code achieves what we want, and the compatibility of various browsers is good, mainly to add the following core code:

display:inline-block; *display:inline; *zoom:1;

You can copy the above instance code and run it here to check the effect.

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.