3

I have a little question about dealing with font size and window width. Sometimes my headers are just one long word and with smaller devices this word is falling of the screen so you only see a small part of the word.

How can I make sure that you always see the full word on every screen?

I have tried several css solutions but than the word breaks and continues on the next rule.

Thanks!

3 Answers3

3

If you want that font-size depends on the width of the screen then you can just easily do it through media queries.

See demo.

h1 {
  font-size: 0.68em;
}
@media screen and (min-width: 768px) {
  h1 {
    font-size: 0.87em;
  }
}
@media screen and (min-width: 992px) {
  h1 {
    font-size: 1em;
  }
}
@media screen and (min-width: 1200px) {
  h1 {
    font-size: 1.5em;
  }
}
  
  
<h1>How can I make sure text never is falling of the screen This is a long header</h1>

You can also go here for more info about different media device screen size

See link

JF-Mechs
  • 1,083
  • 10
  • 23
1

You can use media queries and adapt the text size to different screen sizes.

Ciprianis
  • 255
  • 3
  • 10
1

If you really want a flexible solution, and already use jQuery for other reasons, you can easily use the jQuery-quickfit plugin that does exactly this.

Nick Andriopoulos
  • 10,313
  • 6
  • 32
  • 56