CSS 样式覆盖原理示例介绍
对同一个标签设置多个相同属性,但是值不一样,那么该标签的属性会根据那个设定的为标准呢?
对于同一个标签元素设置属性,满足这样一个规则:元素单独设置的样式>class命名样式>标签样式。样式override父级别的。
复制代码代码如下:
<style type="text/css">
#txt{ background-color:Red}
.txt{ background-color:Green}
input {background-color:Black}
</style>
<input id="txt" type="text" class="txt" />
<input type="text" class="txt" />
<input type="text" />
对于同一个标签元素设置属性,满足这样一个规则:元素单独设置的样式>class命名样式>标签样式。样式override父级别的。
复制代码代码如下:
<style type="text/css">
#txt{ background-color:Red}
.txt{ background-color:Green}
input {background-color:Black}
</style>
<input id="txt" type="text" class="txt" />
<input type="text" class="txt" />
<input type="text" />
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。