The two solutions css justified text

Speaking of text alignment, we all know that text-align, the most commonly used are left, right, center, and today we talk about justify, that is, justifies text. It sounds simple, but some people still have to pay attention to the pits.

Now we have the two lines of text , the actual development, we often encounter such a scenario: the need to align the name and phone number that two paragraphs. We naturally think of text-align: justify; I was thinking, let's try:

 

 

Refresh your browser, why no effect?

The reason is to justify the last line is invalid, and our name only one line, of course, also invalid. Then how do we solve this problem?

We can think of, since to justify the last line is invalid, then we add a line like, as long as it is not the last line not to ok? Of course, we added a line can not be seen by people. Here, we think of the pseudo-elements.

Not add a line of text, we take a look at the page:

Very good, it is clearly met the requirements. However, this will not be too much trouble to write it, programmers pay attention to high efficiency (lazy) people, if they can use a code to complete, is it not happy indeed?

Not to mention, really. Here Amway a new attribute text-align-last, ado, directly on the code:

A code to achieve the requirements.

Nice, nice.

 

Original: https://www.cnblogs.com/wl0804/p/11265225.html

Speaking of text alignment, we all know that text-align, the most commonly used are left, right, center, and today we talk about justify, that is, justifies text. It sounds simple, but some people still have to pay attention to the pits.

Now we have the two lines of text , the actual development, we often encounter such a scenario: the need to align the name and phone number that two paragraphs. We naturally think of text-align: justify; I was thinking, let's try:

 

 

Refresh your browser, why no effect?

The reason is to justify the last line is invalid, and our name only one line, of course, also invalid. Then how do we solve this problem?

We can think of, since to justify the last line is invalid, then we add a line like, as long as it is not the last line not to ok? Of course, we added a line can not be seen by people. Here, we think of the pseudo-elements.

Not add a line of text, we take a look at the page:

Very good, it is clearly met the requirements. However, this will not be too much trouble to write it, programmers pay attention to high efficiency (lazy) people, if they can use a code to complete, is it not happy indeed?

Not to mention, really. Here Amway a new attribute text-align-last, ado, directly on the code:

A code to achieve the requirements.

Nice, nice.

 

Guess you like

Origin www.cnblogs.com/showcase/p/11265392.html