CSS:字体颜色不会改变

时间:2017-10-11 11:56:01

标签: css fonts colors

我的html文件没有使用CSS样式表中定义的字体颜色。它似乎部分有效,但遗憾的是它不能做我想做的事。



* {
  font-family: "verdana"
  color: #FFF;
}

.wrapper {
  display: table;
  width: 100%;
  height: 100%;
  background-color: #000000;
}

.header {
  display: table;
  float: left;
  background-image: url("header.jpg");
  width: 100%;
  height: 250px;
  vertical-align: top;
}

.bodytop {
  display: table;
  clear: both;
  background-image: url(images/header.jpg);
  width: 100%;
  vertical-align: top;
  background-color: #444444;
}

.bodybottom {
  display: table;
  width: 100%;
  vertical-align: top;
  background-color: #666666;
}

.buttonbox {
  display: table;
  width: 150px;
  height: 150px;
  background-color: #888888;
  vertical-align: middle;
  margin: 15px;
}

<htmL>

<head>
  <link rel="stylesheet" type="text/css" href="css/stylesheet.css">
  <title></title>
</head>

<body>
  <div class="wrapper">
    <div class="header">
      <!--Header, the first 250px from the top-->
      <div class=bodytop>
        <!--upper part of the website-->
        <center>
          <div class="buttonbox">
            Dit is button3
          </div>
          <div class="buttonbox">
            Dit is button2
          </div>
          <div class="buttonbox">
            Dit is button1
          </div>
        </center>
        <div class=bodybottom>
          <!--Lower part of the website-->
        </div>
      </div>
    </div>
  </div>
</body>

</htmL>
&#13;
&#13;
&#13;

代码似乎正在工作,因为字体已更改为Verdana但颜色不会发生变化。

3 个答案:

答案 0 :(得分:3)

你的font-family后面缺​​少一个分号:

$statement = $pdo->prepare('INSERT INTO test(datablob) VALUES(?);');
$data = fopen('file.txt');
$statement->bindParam(1,$data,PDO::PARAM_LOB);
$statement->execute();
*{
  font-family: "verdana"; /* Missing this semi-colon. */
  color: #FFF;
}
.wrapper
{
  display: table;
  width: 100%;
  height: 100%;
  background-color: #000000;
}
.header
{
  display: table;
  float: left;
  background-image: url("header.jpg");
  width: 100%;
  height: 250px;
  vertical-align: top;
}
.bodytop
{
  display: table;
  clear: both;
  background-image: url(images/header.jpg);
  width: 100%;
  vertical-align: top;
  background-color: #444444;
}
.bodybottom
{
  display: table;
  width: 100%;
  vertical-align: top;
  background-color: #666666;
}
.buttonbox
{
  display: table;
  width: 150px;
  height: 150px;
  background-color: #888888;
  vertical-align: middle;
  margin: 15px;
}

答案 1 :(得分:3)

这是因为特异性。您已为color(通用选择器)设置了*。对于特定元素,您需要设置颜色。而且,只有一个color,它位于通用选择器中。

此外,您的CSS有错误:

font-family: "verdana"
//--------------------^ No Semi colon.
* {
  font-family: "verdana"; /* Corrected */
  color: #FFF;
}

.wrapper {
  display: table;
  width: 100%;
  height: 100%;
  background-color: #000000;
}

.header {
  display: table;
  float: left;
  background-image: url("header.jpg");
  width: 100%;
  height: 250px;
  vertical-align: top;
}

.bodytop {
  display: table;
  clear: both;
  background-image: url(images/header.jpg);
  width: 100%;
  vertical-align: top;
  background-color: #444444;
}

.bodybottom {
  display: table;
  width: 100%;
  vertical-align: top;
  background-color: #666666;
}

.buttonbox {
  display: table;
  width: 150px;
  height: 150px;
  background-color: #888888;
  vertical-align: middle;
  margin: 15px;
}

答案 2 :(得分:2)

看起来你的CSS缺少一个分号,它应该是:

* {
    font-family: "verdana";
    color: #FFF;
}