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

现在这种情况 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优先级最高

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!