6 ms·
Can you give an example where somebody used JS inside CSS for a solution CSS alone could have provided? EDIT: I can't seem to reply down below, but in my plugi
by err4nt 11y ago
Can you give an example where somebody used JS inside CSS for a solution CSS alone could have provided?
EDIT: I can't seem to reply down below, but in my plugin for example we've implemented a few responsive conditions:
- min-scroll-x
- max-scroll-x
- min-scroll-y
- max-scroll-y
So if you needed to trigger a style (or a whole block of styles) when the page, or any element you specify has a scroll position meets the conditions above.
By combining these conditions with other conditions, it makes it DEAD simple for CSS-only designers to be able to write responsive JavaScript!
@element 'body' and (min-width:900px) and (min-scroll-y: 100vh) {
header {
position: fixed;
}
}
- herbst 11y agoI cant simply provide a solution for your edit thats true. But i assume this to create massive overhead just to enable CSS do something it never was supposed to? It maybe just does not fit into my world view, but thats simply wrong to my eyes CSS is not supposed to know that much about the view.
- herbst 11y agoSure. Most of the time they used it to trigger jQuery fadeIn/fadeOut or move boxes which would have moved if the CSS would have followed a basic grid system other than a <div> construct reassembling tables. Its a worstcase probably, but i also do not find any sitations where it would make more sense to traditional methods.