Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Media Query Breakpoints Headache Reply To: Media Query Breakpoints Headache

#243459
Atelierbram
Participant

There is no CSS equivalent to jQuery insertAfter, insertBefore, etc. So how would you achieve all that

That is not what I meant with:

because of having that logic in two places: in JavaScript and in the CSS media-queries: it’s confusing

What I mean is handling the logic in the mediaqueries in one place. And for me that place would be CSS.
So for example in the jQuery javascript there are styles set and unset with .css and .removeAttr("style"). When this would be done with adding, removing and/or toggling classes, then those classes could be targeted and styled within the CSS mediaqueries: in my opinion it’s easier that way to see what’s going on. That will also make it easier to progressively enhance the layout.

Anyway there is a 15px difference between the calculated width in the javaScript and in the CSS (when checked in DevTools). So maybe jQuery $(window).width() doesn’t take the vertical scrollbar into account or something (so this also may vary in different browsers).