CSS 如何删除css中的element.style
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2622372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to remove element.style in css
提问by useranon
I am using Joomla 1.5.
i am having a page where a cSS has been added for the title
which is in <strong></strong>
我正在使用 Joomla 1.5。我有一个页面,其中已为标题添加了 CSS<strong></strong>
I firebug it , it appears as
我烧毁它,它看起来像
element.style {
color:#666666;
}
i dont know of from where it comes from..
我不知道它来自哪里..
but i am having a css applied for the same tag with other color. but it disappeared. How to remove the element.style globally..
但我有一个 css 应用于具有其他颜色的相同标签。但它消失了。如何全局删除 element.style..
回答by George Wiscombe
It is possible to override inline styles from an external stylesheet
可以从外部样式表覆盖内联样式
strong[style] { color: blue !important; }
This works in most major browsers, Chrome, Safari, Firefox, IE8
这适用于大多数主流浏览器,Chrome、Safari、Firefox、IE8
It doesn't work (to my knowledge) in IE6 / IE7
它在 IE6 / IE7 中不起作用(据我所知)
Hope this helps.
希望这可以帮助。
回答by Rui Carneiro
This code comes from HTML and not from your CSS.
此代码来自 HTML 而不是来自您的 CSS。
This HTML with generate your element.style:
这个 HTML 生成你的 element.style:
<strong style="color:#666666;">Just text</strong>
Element.style, as the name says, its the style defined on element and there is no way to override it. If you do not want that color in that element you must remove/change it on html.
Element.style,顾名思义,就是定义在元素上的样式,无法覆盖。如果您不想在该元素中使用该颜色,则必须在 html 上删除/更改它。
回答by eriq
It seems it is not always set in HTML. In My case the element.style is empty:
似乎它并不总是在 HTML 中设置。在我的情况下 element.style 是空的:
element.style {
}
It is notset in any css and it is notset in any html source. I dont't know where else I should look.
它未在任何 css 中设置,也未在任何 html 源中设置。我不知道我还应该去哪里找。
回答by Ucinorn
Inline styles are generated from HTML or (more often these days) javascript applying styles after the page had loaded.
内联样式是从 HTML 或(现在更常见)页面加载后应用样式的 javascript 生成的。
Jquery is often a culprit of this, performing animations using css applied directly on the element that overrides your stylesheet.
Jquery 通常是造成这种情况的罪魁祸首,它使用直接应用于覆盖样式表的元素上的 css 来执行动画。
For instance you may show, then hide a div, leaving a 'display:none' on the element that overrides any naturally cascading CSS that precedes it. This comes up often when you are mixing CSS transitions and media queries with javascript.
例如,您可以显示,然后隐藏一个 div,在覆盖它之前的任何自然级联 CSS 的元素上留下一个 'display:none'。当您将 CSS 转换和媒体查询与 javascript 混合时,经常会出现这种情况。
Check your JavaScript for any instances of applied styles.
检查您的 JavaScript 是否有任何应用样式的实例。
Try using a callback function on the animation to clear styles:
尝试在动画上使用回调函数来清除样式:
$(this).css( "display", "" );