日期:2014-05-16 浏览次数:20350 次
<div class="ClassificationPanel"> <a class="ClassificationIcon Icon1">家具风格</a> <span class="ClassificationLink"> <a href="#">欧式古典</a> <a href="#">欧式田园</a> <a href="#">美式古典</a><br /> <a href="#">美式田园</a> <a href="#">韩式田园</a> <a href="#">韩式古典</a><br /> <a href="#">更多..</a> </span> </div>
.ClassificationPanel { width:360px; height:80px; display:inline-block; background-color:#ffffe0; margin:5px 0px 0px 5px; float:left; } .ClassificationIcon { background-image:url('/images/classificationIcon.png'); width:86px; height:80px; display:inline-block; float:left; text-align:center; line-height:130px; float:left; cursor:pointer; } .Icon1 { background-position:0px 0px; } a.Icon1:hover,a.Icon1:active { background-position :-87px top; color:White; }
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> <style type="text/css"> .ClassificationPanel { width:360px; height:80px; display:inline-block; background-color:#ffffe0; margin:5px 0px 0px 5px; float:left; } .ClassificationIcon { background-image:url('/images/classificationIcon.png'); width:86px; height:80px; display:inline-block; float:left; text-align:center; line-height:130px; float:left; cursor:pointer; } .Icon1 { background-position:0px 0px; } a.Icon1:hover,a.Icon1:active { background-position :-87px top; color:White; } </style> </head> <body> <div class="ClassificationPanel"> <a class="ClassificationIcon Icon1" onmouseover="set(this)" onmouseout="out()">家具风格</a> <span class="ClassificationLink"> <a href="#">欧式古典</a> <a href="#">欧式田园</a> <a href="#">美式古典</a><br /> <a href="#">美式田园</a> <a href="#">韩式田园</a> <a href="#">韩式古典</a><br /> <a href="#">更多..</a> </span> </div> <script> var cur; function set(t){ t.parentNode.style.backgroundColor = '#a13a35'; cur = t; } function out(){ if( cur ){ cur.parentNode.style.backgroundColor = ''; } } </script> </body> </html>
------解决方案--------------------
试试css伪类就可不可以解决
.ClassificationIcon:hover{<