我正在制作导航菜单。
当我将鼠标悬停在菜单文本上时,会出现一个边框底部,但随之而来的是文字向上移动。
.b-b {
border-bottom: thin #cadadd solid;
}
.row_height {
height: 46px;
}
.menu_div {
display: table-cell;
vertical-align: bottom;
height: 46px;
}
.menu_div span {
position: relative;
bottom: 3px;
}
.menu_div:hover {
border-bottom: 2px solid #353f51;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="row b-b row_height">
<div class="col-lg-2">
<div class="menu_div">
<span>Home</span>
</div>
</div>
</div>
&#13;
任何帮助都会很棒。
谢谢。
答案 0 :(得分:3)
.menu_div {
border-bottom: 2px solid transparent;
}
答案 1 :(得分:2)
为元素.menu_div
设置一个不可见的底部边框,如下所示:
.menu_div{
display: table-cell;
vertical-align: bottom;
height:46px;
border: 2px solid transparent;
}
.b-b {
border-bottom: thin #cadadd solid;
}
.row_height {
height: 46px;
}
.menu_div {
display: table-cell;
vertical-align: bottom;
height: 46px;
border: 2px solid transparent;
}
.menu_div span {
position: relative;
bottom: 3px;
}
.menu_div:hover {
border-bottom: 2px solid #353f51;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="row b-b row_height">
<div class="col-lg-2">
<div class="menu_div">
<span>Home</span>
</div>
</div>
</div>
&#13;