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

现在这种情况 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级讲师

全員に返信(1)
黄舟

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

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!