覆盖CSS中的属性 [英] Overriding properties in CSS

查看:79
本文介绍了覆盖CSS中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#iddiv span {
    display: inline-block;
    width: 190px;
}
.myclass {
    width:10px;
}

然后我有

<div id="iddiv">
    <span>hello:</span> 
    <span class="myclass">yeah</span> <br/>
</div>

我想要第一个 span width 为190px,第二个为10px。但两者都是190px:为什么它不会覆盖 width propoerty?

I would like the first span's width to be 190px, and second's to be 10px. But both are 190px: why it's not overriding the width propoerty?

编辑:感谢您的回复。如何设置宽度?我不想要10px宽度,只是默认宽度,因为它是未定义

Thanks for your responses. What about unsetting width? I don't want 10px width, just default width as if it was undefined

推荐答案

比一个类更具体。

#iddiv span.myclass

#iddiv .myclass

适用于这种情况。

了解CSS特性的更多信息这里或Google搜寻。

Learn more about CSS specificity here or by Googling it.

这篇关于覆盖CSS中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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