我有一個菜單,包含一個無序列表,樣式看起來像一個網格,網格框在鼠標懸停在上面時會改變顏色。乾淨利落。我的問題是當我添加一個鏈接到li
裏面的文本時,懸停基本上就會中斷。 (請參閱下面的小提琴以供參考,以及鏈接和非鏈接之間的懸停方式如何不同li
)HTML列表樣式鏈接
我需要將鏈接樣式設置爲與懸停在網格上時的無風格文本相同的樣式,而不僅僅是實際的鏈接並使整個網格框區域可點擊。
我一直在搞它一段時間,但不能讓它按我想要的方式工作。
<style>
.admin-panel {
overflow: hidden;
li {
float: left;
width: 33%;
height: 115px;
padding: 10px;
line-height: 1.4;
text-align: center;
background-color: #f9f9f9;
border: 1px solid #fff;
}
li:hover, li a:hover {
color: #fff;
background-color: #778ba1;
}
.glyphicon {
margin-top: 5px;
margin-bottom: 10px;
font-size: 24px;
}
.admin-panel-class {
display: block;
text-align: center;
-ms-word-wrap: break-word;
word-wrap: break-word;
}
}
</style>
<div class="admin-panel">
<ul class="admin-panel-list">
<li>
<a href="#">
<span class="glyphicon glyphicon-list-alt"></span>
<span class="admin-panel-class">My Workshops</span>
</a>
</li>
<li>
<span class="glyphicon glyphicon-star"></span>
<span class="admin-panel-class">Create Workshop</span>
</li>
<li>
<span class="glyphicon glyphicon-pencil"></span>
<span class="admin-panel-class">Edit Workshop</span>
</li>
<li>
<span class="glyphicon glyphicon-asterisk"></span>
<span class="admin-panel-class">Resource Allocation</span>
</li>
<li>
<span class="glyphicon glyphicon-ok"></span>
<span class="admin-panel-class">Reservation Approval</span>
</li>
<li>
<span class="glyphicon glyphicon-ok"></span>
<span class="admin-panel-class">Facilities Reservation Approval</span>
</li>
<li>
<span class="glyphicon glyphicon-calendar"></span>
<span class="admin-panel-class">Room Calendars</span>
</li>
<li>
<span class="glyphicon glyphicon-stats"></span>
<span class="admin-panel-class">Global Reports</span>
</li>
<li>
<span class="glyphicon glyphicon-phone"></span>
<span class="admin-panel-class">Sing-In Tablets</span>
</li>
<li>
<span class="glyphicon glyphicon-th-list"></span>
<span class="admin-panel-class">Menu Editor</span>
</li>
<li>
<span class="glyphicon glyphicon-user"></span>
<span class="admin-panel-class">Edit Users</span>
</li>
</ul>
</div>
是[這](HTTPS: //jsfiddle.net/DTcHh/15128/)你需要什麼? – Harry
在你的例子中的懸停很好,謝謝,現在唯一的辦法是使整個網格框區域可點擊而不是僅可點擊文本 – esausilva
但你的''''有10px的填充。可以單獨使用10px以外的空間嗎?否則,我們可能不得不使用絕對定位。 – Harry