What is adaptive width?

Source: Internet
Author: User

The general requirements and situations are as follows. the Code submitted today feels like a better version. The code quality is closely related to the personal programming knowledge and experience. If you don't want the best, you can ask better and better. here is a summary.

When the content exceeds the width of the parent element, it will automatically wrap when white-space: nowrap is not set. The white-space: nowrap style cannot be associated with the extended part of the scroll bar, the solution is as follows:

1. Add the white-space: nowrap attribute to the parent element;

2. Calculate the content width of each line;

A. Split the content, including indentation, images, and text.

B. The text width is calculated by adding a non-wrap dom element at the end of the body in "Let's Talk About line feed processing.

C. The width of the stacked Shard is the total width.

3. Remove the white-space: nowrap attribute of the parent element;

4. Set the maximum width of 2 to the width of the parent element (it is best to add the 6px-8px width to the scroll bar based on the precise width. First, the scroll bar appears, (2 ).

Advantages of this method (compared with the previous solutions ):

1. The width calculation is accurate.

2. Stable performance. You can traverse the nodes once without repeating the test process.

What's more, work is always under various business scenarios, as the problem solved above is.

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.