Cascading CSS
-
CSS. I have to redesign a horribly convoluted frames based site with no frames. This is a Good Thing. One problem - there's a small block that has to use (for reasons I have no control over) it's own stylesheet, completely independant of the main CSS (that is, the content will be independant - the block itself has to be sized and placed using the site CSS...). And it has to be inside a larger block level element that will take the site CSS. Is there a way to stop the CSS cascading, or reset every property of the block, or do I have to manually reset each inheritable property separately?
-
Answer:
Even your worst case scenario doesn't sound too bad here. Sure, most properties inherit, but having to set #independantblock { blahblahblah blahblahblah } #independantblock a { blahblahblah } doesn't seem that trying to me. Or am I missing something?
monkey closet at Ask.Metafilter.Com Visit the source
Other answers
I think you can get away with this: #independentblock * { reset defaults } to reset any properties that apply to everything inside. Not sure if that's helpful or not, but it would at least let you shut off all padding, margin , borders and whatever else you didn't want inherited.
yerfatma
does the "*" work in CSS, in all the usual browsers?
signal
Yes, the * does work. Eric Meyer's been talking about interesting CSS tricks--try using a stylesheet with nothing but this in it: * {display: block;} It'll reveal all the HEAD elements, fun stuff like that.
adamrice
Unfortunately, since the "clear" property pushes a block below all floated blocks - not just those in the parent element - you can't reliably use CSS for templates when the nested content may have its own styles. Use tables. (I would love to be proven wrong about this!)
nicwolff
Nicwolff-- Check out http://crossroads.net/misc/floattest.html I think you're wrong. It's not pretty, and may not do what you want, but the clearing effect does appear to happen within the parent--it doesn't clear everything.
adamrice
Nope, the "clear: right" block there clears past all "float: right" blocks, whether they're in the parent div or not. http://angel.net/~nic/cleartest.html of the problem as it arises trying to do a two-column template with CSS, in which arbitrary content might come from a data store. I've just done http://fixprotocol.org/ in which the client was (ah, bliss!) dedicated to an all-CSS layout and I regretfully had to revert to tables for the main three-column template because any "clear" attributes in the content blew up the columns. I think this is a serious flaw in CSS, and as I said I'd love to find a way around it without tables.
nicwolff
Related Q & A:
- How do you search DOM elements using CSS selectors in Chrome?Best solution by Stack Overflow
- How to apply custom css to CKEditor?Best solution by stackoverflow.com
- How to save ONLY the CSS changes of Styles panel of Chrome Developer Tools?Best solution by Stack Overflow
- How to change links in CSS?Best solution by Stack Overflow
- Is it possible to use SVG images as CSS background?Best solution by helephant.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.