Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there is a way to automatically tell HTML/CSS to adjust the font size automatically? For example, iOS UILabel has adjustsFontSizeToFitWidth. Does HTML have anything similar?


I don’t believe so. It would be hugely useful, but I have found the iOS implementation to be kind of wonky, so I’d rather it not come to web unless the idea can be perfected.

Also I think a proper implementation would require reference to line count in the CSS markup, and CSS seems to have an awful time with properties that depend on character or line counts. We still don’t have working line-clamp!

ex.

  div {
    font-size: 24px;
  }
  div[line-count > 2] { // doesn’t exist, and must be difficult to implement
    font-size: fit-width; // … what about vertical text?
    min-font-size: 8px; // maintain legibility
    max-font-size: 28px; // why not
  }
Sure would make a lot of my designers happy, though…




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: