search

Home  >  Q&A  >  body text

css - 样式写在行间的怎么改变hover时的颜色呢?

现在这种情况 hover时不能改变背景颜色 但是样式只能写在行间 不能写在样式表里面 这种情况hover时怎么才能改变背景颜色呢?

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
    ul,li,a,body{margin: 0;padding: 0;}
    ul{display:inline-block;width: 100px;height: 400px;}
    li{list-style: none;width: 100px;height: 100px;display: inline-block;line-height: 100px;text-align: center;}
    a{display: inline-block;width: 100%;height: 100%;}
    a.name:hover{background-color: blue;}
    </style>
</head>
<body>
<ul>
    <li><a class="name" style="background-color: yellow;" href="#">1</a></li>
    <li><a class="name" style="background-color: yellow;" href="#">2</a></li>
    <li><a class="name" style="background-color: yellow;" href="#">3</a></li>
    <li><a class="name" style="background-color: yellow;" href="#">4</a></li>
</ul>
</body>
</html>
PHP中文网PHP中文网2782 days ago1042

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-17 13:37:18

    a.name:hover{background-color: blue!important;}
    Add important with the highest priority

    reply
    0
  • Cancelreply