css基础学习---简单理解

时间:2023-03-09 21:51:33
css基础学习---简单理解

1:在css中定义图片相对路径

#primary-nav {
//相对路径
background: url(../images/alert-overlay.png) repeat-x;
height: 35px;
font-size: 10px;
color: #fff;
line-height: 34px;
background-color: #222;
margin: 0 auto;
max-width: 1128px;
font-weight: bold;
font-family: Verdana,Arial,Helvetica,sans-serif;
box-shadow: 1px 2px 5px 1px #808080;
}

对应文件结构

css基础学习---简单理解css基础学习---简单理解

2:下面display为什么要加important

.main-navigation a {
color: #5e5e5e;
//为什么要加!important
padding: 0 15px!important;
}

css基础学习---简单理解

加!important就表示提升这个属性的优先级 比如说你如果在其它地方又写了一个display:inline之类的 还会按照你这里的block进行解释 

另外IE6是不认!important的 可以利用这个特性来给不同的浏览器做不同的css设置