CSS is centered when it is not a single line, with more than one line justified

Source: Internet
Author: User

Today, there is a problem, not enough to center a good-looking, more than one line centered and difficult to see:

Center

Justify on both sides

First want to use Text-align-last:center; But the result is this:

The center of a single line

But the last line of multiple lines is also centered ...

Later changed to this:

1 <Divclass= "text"><P>2. Tap WiFi Key Search</P></Div>2 <Divclass= "text"><P>3. Please wait 5-15 secs in your Wi-Fi Settings for WiFi list to load. Tap on hotspots with "Wi-Fi Master key WiFi key Search" to connect</P></Div>
. Text{width:285px;margin:Auto;padding:8px;Background-color:#d8d8d8;text-align:Center;font-size:15px;Color:#333;}. Text P{Display:Inline-block;margin:Auto;text-align:Justify;}

can let P text-align:justify;display:inline-block; Add an outer box div to P, this outer box text-align:center;
So p changes with the width of the text, and P is centered in the Div, and it looks centered when the P-width is not enough.

The effect is realized

The CSS is centered when it is not a single line, and is justified on more than one line

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.