悬停物品,你会看到wrap将调整大小悬停在第二个标题上.
怎么预防这个?
*{
margin:0;
padding:0;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
.wrap{
position:fixed;
min-width:140px;
}
.title{
padding:3px 25px 3px 9px;
background:gold;
}
.title:hover{
border-right:10px solid lightseagreen;
}Run Code Online (Sandbox Code Playgroud)
<div class='wrap'>
<div class='title'>lorem</div>
<div class='title'>loremxxxxxxxxxxx</div>
<div class='title'>lorem</div>
<div class='title'>lorem</div>
</div>Run Code Online (Sandbox Code Playgroud)
最好的简单解决方案是将title颜色的边框应用为透明,然后悬停更改边框的颜色.
检查下面
.title{
..
..
border-right:10px solid transparent;
..
}
.title:hover{
border-right-color: lightseagreen;
}
Run Code Online (Sandbox Code Playgroud)
*{
margin:0;
padding:0;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
.wrap{
position:fixed;
min-width:140px;
}
.title{
padding:3px 25px 3px 9px;
min-width:30%;
background:gold;
margin-right:15px;
border-right:10px solid transparent;
}
.title:hover{
border-right-color: lightseagreen;
}Run Code Online (Sandbox Code Playgroud)
<div class='wrap'>
<div class='title'>lorem</div>
<div class='title'>loremxxxxxxxxxxx</div>
<div class='title'>lorem</div>
<div class='title'>lorem</div>
</div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
42 次 |
| 最近记录: |