The mobile side implements truncation of title text

Source: Internet
Author: User

Applicable Scenarios
When
the screen resolution is 320x500, the module title effect is as follows: when the screen resolution is 480x500, the module title effect is as follows: that is, when the screen resolution is large, display more text, resolution hours display less text, and need to ensure that this part is always fully displayed.
Implementation MethodScenario One: DEMO from @ Shang zhe

    1.   for entire container   and   title text Container   Add Overflow:hidden;text-overflow: Ellipsis;white-space:nowrap;   Ensure content is displayed on one line. The effect is as follows, we need to display the site identity is also omitted, then we then improve the
    2. for title text container Add display: inline-block;max-width:100%; setting the maximum container width is 100%, when we find that the site identity is squeezed to the following
    3. for Site Identity Container add display:inline-block;margin-left:-6em; By setting a negative margin let our site logo be displayed in the header row
    4. for title text container add Padding-right:6em;box-sizing:border-box; By setting the value of the Box-sizing property to Border-box, the position occupied by the Padding-right value is calculated in the header text container, note that the value of Padding-right is exactly the adjusted value of the site identity container margin-left. The result of the adjustment is as follows:
    5. Finally, let's adjust the title text container and site identity container Vertical alignment to align them vertically with the
Scenario Two: DEMO from @guopi
    1. Add display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:80% to the header container ;
    2. Finally, let's adjust the alignment to align the content vertically in the entire container.
Scenario Three: DEMO from @snadn
    1. Add Display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width to the header container : 100%;vertical-align:top; Here we set the vertical center alignment in advance.
    2. Add White-space:nowrap to the whole container ; control the content to a single line
    3. Then add the margin-right:100px for the whole container ; Limit the title content to a certain width, so that the site logo is displayed.
    4. In the above effect, it is found that the gray background is also limited to a certain width, so we put the setting of the background on the whole container , the final effect is as follows:
Scenario four: DEMO from @snadn
    1. Add Display:inline-block for the header container ; White-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width: Calc (100%–100px);
    2. Finally, let's adjust the alignment to align the content vertically in the entire container .
Summary:
    1. Scheme I and programme three are unified for the truncation effect at different resolutions
    2. Scenario two at different resolutions, some differences, such as the resolution of a large number of truncated content, the resolution of the hour content will be truncated less
    3. Scenario four on the mobile side of the compatibility is not very good use caution.

The mobile side implements truncation of title text

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.