標籤:
今天在幫我們學校做網站的時候,由於在css這裡不是很擅長,過程中發現一個問題,a:hover的時候,字型的顏色不變.後來才發現將a和div的嵌套的問題,
我的css代碼為:
.left_box .lb_wrap .lb_theme { color:#900; text-align:center; height:30px; display: block;; margin-left: auto; margin-top: 1px; line-height: 35px;}.left_box .lb_wrap a { display:block; text-align:center; height:30px; width:100%;}.left_box .lb_wrap a:link { color:#900; background: #FFF no-repeat 5px 12px; text-decoration:none;}.left_box .lb_wrap a:hover { color:#FFF; /*滑鼠滑過的時候,字型應該變為該色調(白色),但是實際上沒有*/ background:#800 no-repeat 5px 12px; font-size: 12px; font-weight: bolder; text-decoration:none;}.left_box { border: 1px solid #09F; margin-top: 16px;}/*lb:left box*/.left_box .lb_wrap { width:95%; background:#900; margin-top:5px; margin-left: auto; margin-bottom:30px; font: Arial, "宋體";}
html代碼為:
<div class="left_box"><div class="lb_wrap"> <div class="lb_title">國家、廣西特色專業</div> <a href="/Item/88951.aspx"> <div class="lb_theme">地理資訊系統</div> <!--div不能放在div中,否則a:hover不起作用--> </a> <div class="lb_theme"><a href="/Item/88943.aspx">地理科學(教師教育)</a></div></div>
css - a:hover變色問題