css - 样式写在行间的怎么改变hover时的颜色呢?
PHP中文网
PHP中文网 2017-04-17 13:35:18
0
1
1003

现在这种情况 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中文网

认证0级讲师

Antworte allen(1)
黄舟

a.name:hover{background-color: blue!important;}
加important优先级最高

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!