Topic: How do I set the style of an element based upon what it contains in CSS... (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: you tell me |
posted 07-23-2008 09:56
Hi guys need help here. I have a div of lets say class container' which can contain divs of class 'content'. The divs would be set up to look kinda like this: code: <div class="container"> <div class="content">...</div> <div class="content">...</div> <div class="content">...</div> </div>
|
Paranoid (IV) Inmate From: Norway |
posted 07-23-2008 10:37
not using CCS2, you'll have to use the CSS3 :empy pseudo classe which works in all browsers worth their title. Unfortunately there is no ancestor selector in CSS, so you can't target an element based on whether its children matches some rules. But you probably don't need that. Try: code: .container { display:block; } .container:empty { display:none; } The fact that IE do not support the :empty pseudo class should not be a big deal. Just an empty space the size of the margin/padding of .container, nothing more. |
Lunatic (VI) Inmate From: under the bed |
posted 07-23-2008 13:38
OTH, why would you have an empty container div? |
Paranoid (IV) Inmate From: Norway |
posted 07-23-2008 14:28 |
Bipolar (III) Inmate From: you tell me |
posted 07-23-2008 15:43
Well actually its like this that I have a widget which shows contact information for an individual - same address book project I was on. Now the container divs actually hold grouped contact info eg> One container div holds info like phone details tehother holds infolike fax details etc. |
Lunatic (VI) Inmate From: under the bed |
posted 07-23-2008 20:28
Well, again - all you have to do is not generate an element to hold empty items in the first place. |