有一种方法可以强制样式到一个div元素,它已经有一个style =""属性 [英] Is there a way to force a style to a div element which already has a style="" attribute

查看:282
本文介绍了有一种方法可以强制样式到一个div元素,它已经有一个style =""属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图皮肤HTML输出,我不能控制。其中一个元素是 div style =overflow:auto属性。

在CSS中有一种方法强制 div 使用 overflow:hidden;

I'm trying to skin HTML output which I don't have control over. One of the elements is a div with a style="overflow: auto" attribute.
Is there a way in CSS to force that div to use overflow: hidden;?

推荐答案

您可以在样式的末尾添加!important ,如下所示:

You can add !important to the end of your style, like this:

element {
    overflow: hidden !important;
}

这是你不应该依赖的,但在你的情况下,最好的选择。从分离标记,表示和行为(html / css / javascript)的最佳实践中更改Javascript偏差中的值。

This is something you should not rely on normally, but in your case that's the best option. Changing the value in Javascript strays from the best practice of separating markup, presentation, and behavior (html/css/javascript).

这篇关于有一种方法可以强制样式到一个div元素,它已经有一个style =""属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆