如何在html文档的中间重置css ?

时间:2022-01-07 20:29:21

I wonder if there are any possibility to reset css in middle of page? I have main style, but in one area I would like to use style from tinyMCE generated source. So in tinyMCE source are elements which in editor looks like default browsers style (or like user wants), but in other pages uses style from my main css and from it self inline style. So I get mix of both ant it looks crappy. And I have no idea how to reset main style,.. without iframes.

我想知道是否有可能在页面中间重置css ?我有一个主要的风格,但是在一个领域我想使用来自tinyMCE的源代码。tinyMCE源代码中的元素在编辑器中看起来像是默认的浏览器样式(或者像用户希望的那样),但在其他页面中,则使用来自我的主css和它的自内嵌样式的样式。所以我混合了这两种蚂蚁看起来很糟糕。我也不知道如何重新设定主要风格。没有iframes。

Thanks

谢谢

2 个解决方案

#1


6  

You mean, have a set of CSS rules to apply to the top part of a page, and a reset set of rules apply to the rest? No way, can't be done, sorry.

你的意思是,有一套CSS规则可以应用到页面的顶部,还有一套重置的规则可以应用到其他部分?不行,不行,对不起。

My approach to stuff like this is usually to embed the problematic content in a wrapper <div class='wysiwyg_html'> and then to set specific styling instructions for that content:

我这样做的方法通常是将有问题的内容嵌入到包装器

中,然后为该内容设置特定的样式说明:

.wysiwyg_html p { display: inline }
.wysiwyg_html a { text-decoration: underline }
.... and so on

If you want, you can apply a whole reset stylesheet to everything inside wysiwyg_html that way.

如果需要,可以对wysiwyg_html中的所有内容应用整个重置样式表。

#2


0  

thats pretty easy, i will show this with the "poorman's" reset but the others (eric mayer's ect.) works the same way:

这很简单,我将用《穷人》的重置来展示,但其他的(埃里克·迈耶的ect)也是这样:

* {
padding: 0;
margin: 0;
}

div {
 padding: 50px;
}

#content *{
 padding: 0;
 margin: 0;
}

now your div inside the #content should have the reseted padding: 0; again, because an id selector wins over an element selector, so the only thing you need to make sure is that your secound reset has a selector that outweighs the others (but dont use important!).

现在,#content中的div应该具有reseted填充:0;同样,因为id选择器胜过元素选择器,所以您唯一需要确保的是,secound拥有一个超过其他选择器的选择器(但不要使用important!)

#1


6  

You mean, have a set of CSS rules to apply to the top part of a page, and a reset set of rules apply to the rest? No way, can't be done, sorry.

你的意思是,有一套CSS规则可以应用到页面的顶部,还有一套重置的规则可以应用到其他部分?不行,不行,对不起。

My approach to stuff like this is usually to embed the problematic content in a wrapper <div class='wysiwyg_html'> and then to set specific styling instructions for that content:

我这样做的方法通常是将有问题的内容嵌入到包装器

中,然后为该内容设置特定的样式说明:

.wysiwyg_html p { display: inline }
.wysiwyg_html a { text-decoration: underline }
.... and so on

If you want, you can apply a whole reset stylesheet to everything inside wysiwyg_html that way.

如果需要,可以对wysiwyg_html中的所有内容应用整个重置样式表。

#2


0  

thats pretty easy, i will show this with the "poorman's" reset but the others (eric mayer's ect.) works the same way:

这很简单,我将用《穷人》的重置来展示,但其他的(埃里克·迈耶的ect)也是这样:

* {
padding: 0;
margin: 0;
}

div {
 padding: 50px;
}

#content *{
 padding: 0;
 margin: 0;
}

now your div inside the #content should have the reseted padding: 0; again, because an id selector wins over an element selector, so the only thing you need to make sure is that your secound reset has a selector that outweighs the others (but dont use important!).

现在,#content中的div应该具有reseted填充:0;同样,因为id选择器胜过元素选择器,所以您唯一需要确保的是,secound拥有一个超过其他选择器的选择器(但不要使用important!)