Help - Search - Members - Calendar
Full Version: Multiple conditional selectors
HTMLHelp Forums > Web Authoring > Cascading Style Sheets
Skylark
Hello, first post and all that smile.gif

I have a pretty complex situation which I was hoping to resolve using only CSS. On my Wiki, a given template gives output where some parts are surrounded by <span class="popup">...</span>, and others are surrounded by <span class="notpopup">...</span>. What I would like is to sometimes show the "popup" parts and hide the "notpopup" parts, and other times do the opposite.

What I tried is this: When I want to show popup and hide notpopup, I surround the whole code with another <span class="popup">...</span>

and then my CSS has code like this:

CODE
span.notpopup span.popup {
    display: none;
}

span.popup span.notpopup {
    display: none;
}


But this doesn't work. I'm guessing that I can't have multiple class selectors (i.e. span span.popup might work, but span.notpopup span.popup doesn't)... Does anyone have any idea how I could make this work, or another idea of how to tackle the problem?

(I can change some things in the template's output, but not everything, because the output comes from an extension.)

Thanks,

Skylark
Darin McGrew
CODE
span.notpopup span.popup {
    display: none;
}

span.popup span.notpopup {
    display: none;
}
The first selector applies to a <span class="popup"> that is inside a <span class="notpopup">. The second selector applies to a <span class="notpopup"> that is inside a <span class="popup">.

Is that what you intended to hide?
Skylark
QUOTE(Darin McGrew @ Jul 12 2007, 12:50 PM) *
The first selector applies to a <span class="popup"> that is inside a <span class="notpopup">. The second selector applies to a <span class="notpopup"> that is inside a <span class="popup">.

Is that what you intended to hide?
Yes, and it doesn't seem to work... Is it supposed to work, and in most modern browsers? (I have Firefox 2, but it should work in any browser that supports CSS2 right?)

I guess I'll make a small test case to see if it works in a simpler case, and then expand that to my actual code step by step. I just wanted to see if it was supposed to work in the first place, and see if there was another way to do it.

Thanks,

Skylark
Darin McGrew
Can you provide the URL (address) of a document that demonstrates the problem?
Skylark
QUOTE(Darin McGrew @ Jul 12 2007, 02:16 PM) *

Can you provide the URL (address) of a document that demonstrates the problem?
Thanks for your help, the problem ended up being caused by unbalanced tags interfering with the <span>s... After balancing the tags, it works great. The HTML is generated by a MediaWiki extension, so I assumed it was correct, but I should never assume...

Sorry for wasting bandwidth, and thanks for helping.

Skylark

(edit: if you're still interested, I made a small test case which I can post here.)
Darin McGrew
Please see the FAQ entry How can I check for errors?
Skylark
QUOTE(Darin McGrew @ Jul 12 2007, 05:26 PM) *

Please see the FAQ entry How can I check for errors?
Sure, thanks, I'll keep that in mind. As I said, though, the HTML was being generated by the Wiki (lots of PHP code all over the place, which I didn't write) and I assumed it was correct.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.