CSS无法正常工作

时间:2017-03-06 22:29:51

标签: html css

我不是Web开发人员,但可以阅读CSS文件并实现它。我有一些下面的CSS工作正常除了.topbox每当我尝试在div中使用它时,它只显示为普通文本而不是CSS样式,我尝试重新加载浏览器缓存,我甚至尝试复制和粘贴一些工作和更改名称的CSS,但即使这样也行不通。所以这让我相信我的CSS中某处出现了一个错误导致了这个问题。

.redbox {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  margin: 10px;
  padding: 10px;
  overflow: hidden;
  border: 2px solid rgba(170,75,75,0.7);
  -webkit-border-radius: 10px;
  border-radius: 10px;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: rgba(61,60,60,0.85);
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: rgba(168,10,10,0.45);
  -webkit-box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.2) ;
}
.topbox {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  float: right;
  padding: 5px;
  border: 2px solid rgba(152,0,0,0.7);
  -webkit-border-radius: 1px;
  border-radius: 1px;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: black;
  text-align: center;
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: rgba(224,102,102,0.7);
}

尝试像这样实现它;

<div class="topbox">
    Test<i class="fa fa-trash"></i>
</div>

这不起作用,它只是显示为常规文本。然而..

<div class="redbox">
    Test<i class="fa fa-trash"></i>
</div>

出现就好了......有什么想法吗?

编辑:试图让这更清楚发生了什么......

这是使用上面代码中的class =“redbox”发生的事情..

Exactly what I expect..

但是,当我复制和粘贴完全相同的.redbox CSS到.topbox时,我希望得到相同的结果..这就是我得到的......

I have class="topbox" but I changed the .topbox CSS code to match .redbox, so why is it not showing up the way the above does?

这是更新后的CSS

.redbox {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  margin: 10px;
  padding: 10px;
  overflow: hidden;
  border: 2px solid rgba(170,75,75,0.7);
  -webkit-border-radius: 10px;
  border-radius: 10px;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: rgba(61,60,60,0.85);
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: rgba(168,10,10,0.45);
  -webkit-box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.2) ;
}

.topbox {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  margin: 10px;
  padding: 10px;
  overflow: hidden;
  border: 2px solid rgba(165,161,74,0.65);
  -webkit-border-radius: 10px;
  border-radius: 10px;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: rgba(61,60,60,0.85);
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: rgba(153,148,7,0.35);
  -webkit-box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.2) ;
}

但.redbox按预期显示,而.topbox只显示没有和CSS格式..

2 个答案:

答案 0 :(得分:0)

&#13;
&#13;
.greenbox {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  margin: 10px;
  padding: 10px;  
  overflow: hidden;
  border: 2px solid rgba(76,173,76,0.7);
  -webkit-border-radius: 10px;
  border-radius: 10px;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: rgba(63,63,63,0.85);
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: rgba(10,170,10,0.45);
  -webkit-box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.2) ;
}
.redbox {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  margin: 10px;
  padding: 10px;
  overflow: hidden;
  border: 2px solid rgba(170,75,75,0.7);
  -webkit-border-radius: 10px;
  border-radius: 10px;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: rgba(61,60,60,0.85);
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: rgba(168,10,10,0.45);
  -webkit-box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.2) ;
}
.bluebox {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  margin: 10px;
  padding: 10px;
  overflow: hidden;
  border: 2px solid rgba(75,120,168,0.65);
  -webkit-border-radius: 10px;
  border-radius: 10px;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: rgba(61,60,60,0.85);
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: rgba(7,87,153,0.35);
  -webkit-box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.2) ;
}
.yellowbox {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  margin: 10px;
  padding: 10px;
  overflow: hidden;
  border: 2px solid rgba(165,161,74,0.65);
  -webkit-border-radius: 10px;
  border-radius: 10px;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: rgba(61,60,60,0.85);
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: rgba(153,148,7,0.35);
  -webkit-box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  box-shadow: 1px 1px 1px 0 rgba(0,0,0,0.3) ;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.2) ;
}
.footer {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  margin: 15px 0px 5px 0px;
  padding: 20px;
  overflow: hidden;
  border: none;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: #666666;
  text-align: center;
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: #fafafa;
  -webkit-box-shadow: 0 0 0 0 rgba(0,0,0,0.3) ;
  box-shadow: 0 0 0 0 rgba(0,0,0,0.3) ;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.2) ;
}
.topbox {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  float: right;
  padding: 5px;
  border: 2px solid rgba(152,0,0,0.7);
  -webkit-border-radius: 1px;
  border-radius: 1px;
  font: normal 14px/1 Verdana, Geneva, sans-serif;
  color: black;
  text-align: center;
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  background: rgba(224,102,102,0.7);
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="topbox">
    Test<i class="fa fa-trash"></i>
</div>

<div class="greenbox">
    Test<i class="fa fa-trash"></i>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

似乎这是一个问题,Chrome没有因为某些原因重新加载CSS,即使我清除了缓存并尝试了crtl + f5等等。我必须下载扩展程序..'重装CSS'以便让Chrome工作。