I don't think the "why?" of this question is important...but what I need to do is to text-align:justify
the last line of text from a DIV. Normally, the last line (or the first if there are no other lines, which is the current case) of a div isn't justified, but aligned left. I know it might not make sense at all, but I absolutely need the last line to be justified!
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
I had an issue where some of the above answers worked, but added a visible new line at the bottom - which was unacceptable, because the box had a background color. I fixed the justification with the code below:
jQuery:
HTML:
Why don't you use
text-align: justify;
?It does justify every line. Even if there is just one line.Edit: I think you are looking for this, as scragz said. Anyway, this works only in IE 5.5 and IE 6.
When the !DOCTYPE is HTML5, Kristin's and Jacqui's solutions cause an extra newline, which is hard to remove. If it bothers you (like me), here's yet another idea:
It has another drawbacks: works for single-line text only, and requires modification of the content as shown above, which isn't always feasible/practical. But there are some situations when this is not problem (like in my case). It can even be useful to have control over the positions where the extra space will be inserted. Styles are inline for brevity only, of course. I tested it with recent FFox/IE only.