简体   繁体   English

覆盖内联样式高度自动

[英]Override inline style height auto

<li style="height: auto;">
                <a >Test</a>
            </li>

I have html block as above. 我有上面的html块。 The problem here is that, jquery is injecting an inline css as style="height: auto;" 这里的问题是,jquery正在将内联css注入为style="height: auto;" to li element which is distorting the current makeup. 会扭曲当前妆容的li元素。 How is it possible to overrride height: auto ? 如何超越高度:auto? I tried height: 100%; 我尝试过height: 100%; doesn't work. 不起作用。

Assuming you have no control over the inline styles, you can override them by adding !important to styles in a stylesheet: 假设您无法控制内联样式,则可以通过在样式表中的样式中添加!important来覆盖它们:

 li { height: 100px !important; background: lightblue !important; } 
 <ul> <li style="height: auto; background: green"> <a>Test 1</a> </li> <li style="height: auto; background: green"> <a>Test 2</a> </li> </ul> 

我不知道您要怎么做,但是您尝试过height:inheritheight:initial吗?

It simple, just set !important to the rule 简单,只需设置!对规则很重要

li{
height: 100% !important;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM