How can I prevent css from automatically wrapping code?

Source: Internet
Author: User

An example of line feed after the floating layer is added with margin:

For example, a DIV with a width of pixel PX contains a menu list with a width of 60px and a margin-right value of 20px. If we use the following HTML structure, can this menu list be completely displayed in one line of this DIV?

 
  1. <Div>
  2. <Div> mb5u1 </div>
  3. <Div> mb5u2 </div>
  4. <Div> mb5u3 </div>
  5. <Div> mb5u4 </div>
  6. <Div> mb5u5 </div>
  7. </Div>

The total width of each menu is 80 PX, and the total length of the five menus is PX, while that of the parent layer is only px, according to the floating principle, the 5th menus will be pushed down without a doubt, that is, line breaks.

Let's take a look at my solution:

The code is as follows:

 
  1. <Div>
  2. <Div class = "overflowDiv">
  3. <Div> mb5u1 </div>
  4. <Div> mb5u2 </div>
  5. <Div> mb5u3 </div>
  6. <Div> mb5u4 </div>
  7. <Div> mb5u5 </div>
  8. </Div>
  9. </Div>


The width of the parent layer is pixel PX, the overflowDiv width of the mask layer is set to 400px for the menu, and the overflow is set to hidden. Therefore, it is natural that the 20 more pixels of the mask layer are not displayed.

The menu is in the PX width.

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.