简体   繁体   English

背景颜色不起作用的CSS

[英]background-color not working css

I have a Div tag in aspx page我在 aspx 页面中有一个 Div 标签

<div id="mainDiv">
...........                                
</div>

Following style is working for it all right except background-color .除了background-color之外,以下样式都可以正常工作。 Any changes made in following class also work.在后续课程中所做的任何更改也有效。 background-color is also applied at design time in visual-studio but does not work at run-time. background-color也在视觉工作室的设计时应用,但在运行时不起作用。 Any reasons?有什么理由吗?

#mainDiv
{
    width:95%;
    background-color:Silver;
    font-weight:bold;
    color:Maroon;    
}

Update Instead of background-color:Silver;更新而不是background-color:Silver; , I have tried background-color:Silver !important; ,我试过background-color:Silver !important; but no difference.但没有区别。 However changing color:Maroon;然而color:Maroon; to color:Blue;color:Blue; affects影响

Edit I have no other css files for this page only one css file is linked to it编辑我没有此页面的其他 css 文件只有一个 css 文件链接到它

Edit I had two divs inside the mainDiv there style was float:left when I removed float:left I was able to see the changes in background-color of mainDiv .编辑我在mainDiv中有两个 div 样式是float:left当我删除float:left我能够看到mainDiv background-color的变化。 Still do not know the reason还是不知道原因

而不是Silver尝试使用十六进制颜色代码

background-color:#C0C0C0; 

There may be some conflict wiith other CSS on that page as this works fine:该页面上的其他 CSS 可能存在一些冲突,因为这可以正常工作:

<div id="mainDiv">
    content here
</div>

CSS CSS

#mainDiv {     
    width:95%;     
    background-color:Silver;     
    font-weight:bold;     
    color:Maroon;     
}

See here: JS Fiddle见这里: JS小提琴

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

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