Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Ive used it a few times, but for printviews and the like. The only reasons you are allowed to use important
-
@Codex404 I also use this for certain stuff in desktop layout while the mobile layout has some JavaScript depending on the scroll direction. Now if the browser gets resized to desktop, the !important overrides whatever the JS in mobile layout had been doing so that I don't need the resize handler.
-
@Codex404 what would be better practice? Using a resize handler? That would cost performance.
-
@irene Well of course, that is also there. But media queries alone don't allow to blend the menu in/our depending on the scrolling direction because that is dynamic behaviour.
Suppose the following sequence:
- window width "mobile"
- scrolling down (JS sets menu position to "auto")
- window width enlarged to "desktop" mode
- desktop media query kicks in and selects position "sticky"
- but because it had been set to "auto" via JS, it stays with "auto" since JS has precedence.
Therefore, I set the desktop menu position to "sticky" with "!important" so that it will override possible previous JS activities. Alternative would be to catch the resize, but I don't want to use an unnecessary handler just to avoid "!important". -
@Fast-Nop if you dont use javascript to do styling there is no need for CSS hacks.
-
@Codex404 OK, then how do I blend in/out the menu depending on the scrolling direction without use of JavaScript?
-
@Codex404 yeah OK, but please also include a slight hystereris so that it takes a bit of scroll reversal to trigger an actual direction change. Otherwise, a tattering finger would make the menu blend in/out rapidly, which would be confusing.
-
@Codex404 did you get around to the example? If not, some search engine keywords would probably suffice to get me on the track, but which ones do you recommend?
-
velian3136yI think I may have a bad coworker. I see that keyword a lot and don't know exactly what it means, but judging by the comments I feel like I'm in a pickle.
-
denvit911506y@Charon92 i feel ya. I’ve seen this many times and still don’t get it what people think when they coding :|
-
It’s a great feature for debugging css styles.
But lol! Try something. Be told it is wrong. Never be allowed to learn and correct. Inconceivable! 😂 -
@irene apologies. I guess that was only funny to me. As that was my experience. Couldn’t read javascript without if blocks having curly braces. After a week I could. But too late.
Related Rants
-
mijit19*Builds a web component for a client website* CLIENT: I don't like it, can I have it a tiny bit over to the r...
-
hiessy21hope this isnt a repeat. have a great weekend guys!!!!!
-
viadukt20Front-end developer's to-do list : ☑ Climb Everest ☑ Learn how to speak mandarin ☑ Become god ◻ Verti...
A story of the backend dev. from our client:
"I used !important once now I'm not allowed to do frontend anymore :("
rant
client
frontend
backend