鼠标悬停时更改div内的颜色链接

时间:2016-09-30 11:43:51

标签: html css css3

我尝试更改div中的颜色链接,当我将光标放在div中时,但我无法获得结果

#pag_number {
  float: left;
  position: relative;
  width: 40px;
  height: 40px;
  line-height: 40px;
  margin-right: 3px;
  font-family: Arial;
  font-size: 18px;
  color: #fff;
  text-align: center;
  background-color: #111;
}
#pag_number a:hover {
  font-weight: bold;
  text-decoration: none;
  color: #A9A713;
}
<div id="pag_number"><a href="#1">1</a>
</div>

我尝试使用我放的css直到,但没有得到工作,从来没有当我把光标放在名为 pag_number 的div上获取更改颜色链接

感谢您的帮助,问候

1 个答案:

答案 0 :(得分:6)

如果您希望在悬停<?php class ProductionCompanies extends DataObject { private static $db = array( "CompanyId" => "Int", "Description" => "Text", "Headquarters" => "Varchar", "Homepage" => "Varchar", "LogoPath" => "Varchar", "Name" => "Varchar", ); private static $has_many = array( "Movies" => "Movie" ); } 时更改child element的颜色,则需要在此案例中parent parent:hover > child设置#pag_number:hover a

#pag_number {
  float: left;
  position: relative;
  width: 40px;
  height: 40px;
  line-height: 40px;
  margin-right: 3px;
  font-family: Arial;
  font-size: 18px;
  color: #fff;
  text-align: center;
  background-color: #111;
}
#pag_number:hover a {
  font-weight: bold;
  text-decoration: none;
  color: #A9A713;
}
<div id="pag_number"><a href="#1">1</a>
</div>