I have a div
element that holds one line of text. How can I get this text to fill the width 100%?
text-align:justify
is only working on elements with several lines of text, and has no effect on the div
with single line. Manually adjusting the letter-spacing and word-spacing is ugly and ineffective.
Are there any other alternatives?
Try this:
div {
text-align: justify;
}
div::after {
content: "";
display: inline-block;
width: 100%;
}
<div>
Some sample testing string
</div>
Take a look here for more info.