1. css没有被调用
2. div的高度没有固定,是auto、没有设值或者高度不够
3. div被嵌套
4. div代码不规范
5. 优先级不够
如:
<style>
.header{
background-color: pink;
height: 200px;
width: 200px;
}
.header{
background-color: black;
}
</style>
<div class="header">
</div>
展示的是黑色
解决方法
<style>
.header{
background-color: pink !important;
height: 200px;
width: 200px;
}
.header{
background-color: black;
}
</style>
<div class="header">
</div>
利用 !important 使它为最高级
效果:粉色