问题描述:

Is there a smart way to justify paragraphs inside a fixed-width div tag without wrapping and only changing the word-spacing? See link below.

Cheers

https://jsfiddle.net/TheCoder/zhL895x9/embedded/result/

<style>

div {

border: 1px solid black;

width: 800px

}

p {

font-size:20px;

white-space: nowrap;

}

#par1 {

word-spacing: -21px;

}

#par2 {

word-spacing: 31px;

}

#par3 {

word-spacing: 10.5px;

}

</style>

<div>

<p id="par1">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>

<p id="par2">At vero eos et accusam et justo duo dolores et ea rebum.</p>

<p id="par3">Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>

</div>

网友答案:

from

#par1 {
word-spacing: -21px;
}

to

#par1 {
white-space:pre-line;
}

Making this changes. Hope it may help

相关阅读:
Top