@HiddenLayer555@lemmy.ml
link
fedilink
English
2
edit-2
1M

To be fair, let’s not pretend we haven’t all written JS to resize shit in desperation when the CSS doesn’t work. Though the better way to do this would probably be to listen for the window size change to fire your style changing functions. That makes it behave more like responsive CSS that changes automatically when you resize the window (though with a slight lag sometimes because it’s a lot more computationally expensive). Though it could also be due to the browser putting unused tabs to sleep and stopping JS execution which would be outside the website’s control.

Ephera
creator
link
fedilink
English
11M

Well, the situation you describe, is probably best handled by CSS media queries.

In case you’re not familiar, you can write:

@media (width < 800px) {
  h1 {
    font-size: 110%;
  }
}

…to get smaller headings on mobile, for example.

But yeah, reality may be more ugly. Especially, if you’re using a bulky JS framework, it may be easier to do the JS dance.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 115 users / day
  • 386 users / week
  • 631 users / month
  • 2.33K users / 6 months
  • 1 subscriber
  • 1.65K Posts
  • 36.5K Comments
  • Modlog