Caspid wrote:This topic seems educational.
I have a question: how do I use the DOM Inspector to find selectors with pseudo-classes
In theory, you can't -
https://bugzilla.mozilla.org/show_bug.cgi?id=185431 But, in practice, I do and I'll explain (in detail) how.
Reason I ask: I'm trying to get the Downloads button to hide when it's not being used (there's no active download). So far I have this:
Code: Select all
#downloads-button:not([attention]) {
display:none !important;
}
...but I can't find the selector for completed downloads, and I'd like to learn how.
First, let's take a step back. This is a toolbarbutton, right? So, if this was, say, the #new-tab-button how would we hide that? Well, we wouldn't care about the hover/active/disabled states, we'd just hide #new-tab-button without anything fancy. Same here, so this gives us our first line -
Code: Select all
#downloads-button {
display: none !important;}
So, we code that line in, but comment it out for now, and find out all the states (p/cs) associated with it. -
Open the DOMi up and set it to 'Always on Top' (people either have this by default or use Power Menu, etc) and select #downloads-button so it's showing on the left and have the
DOM Node view showing on the right.
Now click the actual Download button, what changes in DOM Node? Well, indicator - true and open -true suddenly appear, so there's 2 states we didn't know about. Any help to us for this? Nope. So, you now find something to download.....progress and counter appear in the DOM Node. I'm reckoning that seeing as how both came true together, then it doesn't matter which one we pick, the other will follow.
So, we code it up and test it by pausing (another selector) and cancelling -
Code: Select all
#downloads-button {
display: none ;
}
#downloads-button[progress] {
display: -moz-box !important;}
It works and the job is done.
How you want this will look OK and not, as people would first think, be breaking the 'Fiddler's Elbow' rule. That only applies to
unexpected flexing, when you expect it (like when you open the sidebar, etc) then it's fine.
Hopefully, this will give you the way to not only of how to find selectors, but also generally how to approach this type of stuff, i.e. your mindset.