css - How to select all elements excluding a specific one along with all its descendants -
update: may not possible. i'm still looking solution.
i need create css selector select page elements using *
exclude .exception
elements along descendants (!). .exception
element , descendants needs detain initial styles while *
styles should applied other page elements.
important: solution not if styles applied .exception , descendants first , need override initial values manually! i don't want apply styles .exception
and/or descendants @ all!
desired result
please keep in mind trivial example. page need apply solution contains more elements i need generic solution filtering elements. manual selection , overriding elements wouldn't possible there.
http://jsfiddle.net/zv5gf/2/ (initial state, no solution)
solution :not selector - not perfect
this solution not enough because exclude li.exception not exclude descendants. li.exception descendants initial styles lost.
*:not(.exception){ background-color:orange !important; }
and logical solution div.exception , descendants doesn't work (not supported browsers):
*:not(.exception *){ background-color:orange !important; }
how putting background:inherit
children?
*{ background-color:white } *:not(.exception){ background-color:red } .exception *{ background:inherit; }
Comments
Post a Comment