我遇到了css中的邊框問題,它們被設置爲在正常狀態下隱藏,在懸停時爲1px。結果是這樣的:邊框擴大div高度
鼠標懸停時,下排得到由1px的下推。我試圖添加box-sizing:border-box
,但這並沒有幫助。
.menu-sidebar {
margin-top:25px;
}
.iconmenutest{
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
vertical-align: middle;
font-size: 3em;
text-align: center;
background-color:rgba(40,40,40,0.9);
color:gray;
border:hidden;
cursor: pointer;
}
.iconmenutest:hover {
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
background: rgba(40,40,40,0.3);
border: 1px dotted gray;
}
這裏的HTML:
<div class="col-md-12">
<div class="menu-sidebar row">
<div class="col-md-4 iconmenutest">
<div class="iconmenu">
<i class="ion-power"></i>
</div>
</div>
<div class="col-md-4 iconmenutest">
<div class="iconmenu">
<i class="ion-alert-circled"></i>
</div>
</div>
<div class="col-md-4 iconmenutest">
<div class="iconmenu">
<i class="ion-android-add"></i>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 iconmenutest">
<div class="iconmenu">
<i class="ion-power"></i>
</div>
</div>
<div class="col-md-4 iconmenutest">
<div class="iconmenu">
<i class="ion-alert-circled"></i>
</div>
</div>
<div class="col-md-4 iconmenutest">
<div class="iconmenu">
<i class="ion-android-add"></i>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 iconmenutest">
<div class="iconmenu">
<i class="ion-power"></i>
</div>
</div>
<div class="col-md-4 iconmenutest">
<div class="iconmenu">
<i class="ion-alert-circled"></i>
</div>
</div>
<div class="col-md-4 iconmenutest">
<div class="iconmenu">
<i class="ion-android-add"></i>
</div>
</div>
</div>
</div>
</div>
我應該怎麼做,以保持佈局沒有你在圖片中看到的灰線?
無法使用提供的代碼進行復制。 – showdev 2014-12-12 23:42:20