如何让div类样式起作用?

时间:2016-03-16 03:51:57

标签: html css

由于一些奇怪的原因,我的div类样式不起作用。

1.是的,css是否正确链接 2. Yess所有div和css属性都有正确的结束标记

我有一个名为entry-title-first的div类,然后我有entry-title-secondentry-title-third但是由于某种原因,所有类都采用entry-title-first样式导致此问题的原因?

.entry-title-first {
color:#fff;
font-family:Trade Gothic;
font-size:28px;
line-height:26px;
margin-top:-15px;
font-weight:900;
padding-bottom:8px;
}

.entry-title-first a:link, a:visited, a:hover{
color:#fff;
text-decoration:none;
}

.entry-title-second {
color:#000;
font-family:Trade Gothic;
font-size:28px;
line-height:26px;
margin-top:-15px;
font-weight:900;
padding-bottom:8px;
}

.entry-title-second a:link, a:visited, a:hover{
color:#000;
text-decoration:none;
}

HTML

<div class="entry-title-first"><a href="/">Link Name</a></div>
<div class="entry-title-second"><a href="/">Link Name</a></div>

1 个答案:

答案 0 :(得分:3)

你需要这样做

.entry-title-first a:link, .entry-title-first  a:visited {
  color:#fff;
  text-decoration:none;
}
.entry-title-first a:hover {
  color:#f00;
}

样品

body {
  background: gray;
}
.entry-title-first {
  color:#000;
  font-family:Trade Gothic;
  font-size:28px;
  line-height:26px;
  margin-top:15px;
  font-weight:900;
  padding-bottom:8px;
}

.entry-title-first a:link, .entry-title-first  a:visited {
  color:#fff;
  text-decoration:none;
}
.entry-title-first a:hover {
  color:#f00;
}

.entry-title-second {
  color:#000;
  font-family:Trade Gothic;
  font-size:28px;
  line-height:26px;
  margin-top:15px;
  font-weight:900;
  padding-bottom:8px;
}

.entry-title-second a:link, .entry-title-second a:visited {
  color:#000;
  text-decoration:none;
}

.entry-title-second a:hover {
  color:#ff0;
}
<div class="entry-title-first"><a href="/">Link Name 1</a></div>
<div class="entry-title-second"><a href="/">Link Name 2</a></div>

相关问题