johno Posted March 23, 2006 Share Posted March 23, 2006 Hey!Does anybody know of a way to "exclude" a css rule for a single element?For example, say I wanted to hide everything on a page, EXCEPT for ID "doNotHide". <style>body {display: none;}.doNotHide {/* Do not hide me! *\}</style> Thanks a lot John Link to comment Share on other sites More sharing options...
boen_robot Posted March 23, 2006 Share Posted March 23, 2006 <style>body {display: none;}.doNotHide {display: block;}</style> maybe this?after all, the fact that doNotHide is a class name and (supposibly) belongs to a child of body, it means it's treated with higher priority, making everything besides it invisible.Just notice that in the above case, your elements from this class should be block elements. Otherwise, they'll get the features of block elements. Link to comment Share on other sites More sharing options...
johno Posted March 23, 2006 Author Share Posted March 23, 2006 Thanks for the reply! <html xmlns="http://www.w3.org/1999/xhtml"><head><style>body {display: none;}.doNotHide {display: block;}</style></head><body>I SHOULD VANISH, LIKE MAGIC!<p class="doNotHide">I should still be here :)!<hr></p></body></html> Nothing seems to appear. Link to comment Share on other sites More sharing options...
Err Posted March 23, 2006 Share Posted March 23, 2006 Try this CSS instead then: <style type="text/css">body { visibility: collapse;}.doNotHide { visibility: visible;}</style> Link to comment Share on other sites More sharing options...
johno Posted March 24, 2006 Author Share Posted March 24, 2006 Same Try this CSS instead then:<style type="text/css">body { visibility: collapse;}.doNotHide { visibility: visible;}</style> <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Err Posted March 24, 2006 Share Posted March 24, 2006 Whoops, it works fine on firefox, but not IE (as always ) I was also using a transitional dtd. Link to comment Share on other sites More sharing options...
Webworldx Posted March 24, 2006 Share Posted March 24, 2006 W3 CSS Rules: display: none This value causes an element to generate no boxes in the formatting structure (i.e., the element has no effect on layout). Descendant elements do not generate any boxes either; this behavior cannot be overridden by setting the 'display' property on the descendants. Link to comment Share on other sites More sharing options...
scott100 Posted March 24, 2006 Share Posted March 24, 2006 Try this, works on IE, FF and Opera. Basically just put everything in a div and hide it, not the body. <html xmlns="http://www.w3.org/1999/xhtml"><head><style>.hide {visibility:hidden;}.doNotHide {visibility:visible;}</style></head><body><div class="hide">I SHOULD VANISH, LIKE MAGIC!<p class="doNotHide">I should still be here :)!</p><hr class="doNotHide" /></div></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now