Increase space between words to occupy the width of the div?

Asked

Viewed 622 times

1

I have a text that I would like to "stretch", that is, leave spacing between letters until the end of the div, is there any way to do it? A div must have height static. I can use both Jquery as CSS.

I’ve searched a lot of places but I could only see the font-size but that’s not what I intend.

  • When you say "stretch," you mean height or width?

  • Width, because as I said, I didn’t want to change the height

  • There is a hack with the element after: https://jsfiddle.net/trp2ck2h/1/. This is what you need?

  • Maybe this algorithm will help you: http://jsfiddle.net/DMw6Z/, adjusts the property letter-spacing according to the width of the parent element (parent).

  • @Andersoncarloswoss That’s exactly what I needed! Add as response and it will be accepted.

1 answer

1


It has the "Letter-Spacing" elements for width, the "line-height" for height and the "word-Spacing" for space in the words in css, I don’t know if that’s exactly what you want:

p {
    letter-spacing: 5px;
    line-height: 30px;
    word-spacing: 50px;
}
<p>Eu tenho um texto que eu gostaria de "esticar", ou seja, deixar espaçamento entre letras até que chegue ao fim da div, existe alguma forma de o fazer? A div tem de ter height estática. Posso usar tanto Jquery como CSS.</p>

  • I wanted the phrase with about 4 words to occupy 1 single line.

  • you have an example?

  • Anderson’s response will serve as an example.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.