tags:

views:

50

answers:

3

Hello,I found a lot of posts about css override,but still need to ask. Have this problem.In my wordpress theme links,buttons,p,div,... elements are defined,but I need to in my div box override all previous defined values,just to clear it.How can I do that,here is the structure of my div box

<div class="nBox">
    <div id="skr" class="newsBox scrollable">
        <div class="items">

        <div class="this-one">

         I here load programmaticly text from Tinymce editor,
         with tags and his own defined styles and values.

        </div>

Is there a way to clear previous defined style,so in my div.this-one everythings works fine.

A: 

Just make a selector that has higher weight and it will override previous styles - make sure you really override all previously set rules.

.nBox .this-one {
padding:0;
margin:0;
....
}

You could also override it with ID. ID has a higher weight than class - but note ID must be unique.

Here you can read a bit about it: http://www.webteacher.ws/2008/05/19/tip-calculate-the-specificity-of-css-selectors/

easwee
Tnx I will try you solution.
It isnt working,using !important is only solution,or to load iframe in div tag
A: 

TinyMCE live in an iframe, which shouldn't be effected by styles on the page. If you absolutely need to do this though, I would look for a css reset stylesheet, and then put div.items<space> before each rule in the stylesheet (and remove body level rules of course)

Matt Briggs
The editor is in iframe - not the loaded content on page.
easwee
No,no,I save text from tinymce to database with all tags,than later load in div.Text is just save from tinymce,later dont have anything with it.
A: 

I don't know of any method to just say style: none that would negate any and every possible style rule that an element has inherited. But since most things that you would want to wipe are going to be related to fonts/text, color, or margins/padding, you could take care of most issues with a few simple rules:

.this-one {
   margin: 0; !important
   padding: 0;!important
   font: none;!important
   background: none;!important
}

Then set the values you do want.

Anthony
I know about important,but,when text is load into div,it contains,some times p,ol,ul,li,... and other tags.So it is not a good solution to write imporatan for all tags.