鼠标hover显示红色边框这种效果怎么实现

谁做过这种效果
这是我写的,使用border-right:1px solid #eee;border-bottom:1px solid #eee;鼠标悬浮时ul li:hover{border-color:#ed9639;}怎么让左边也有一像素红框
图片描述

阅读 7.9k
8 个回答

看起来好像每个项题主都只有右边跟下边?

我感觉改成每个项都有左边跟下边,hover的时候再通过设置相邻元素的左边颜色如何?

示例:

*{
    box-sizing:border-box;
}
.wrap{
    width:300px;
    
}
.item{
    width:75px;
    float:left;
    text-align:center;
    border:1px solid #eee;
    border-right-width:0;
}
.item:last-child{
    border-right-width:1px;
}

.item:hover{
    border-left-color:red;
    border-bottom-color:yellow;
}
.item:hover + .item{
    border-left:1px solid yellow;
}
.item:last-child:hover{
    border-right:1px solid yellow;
}
<div class="wrap">
    <div class="item">
        hello
    </div>
    <div class="item">
        hello
    </div>
    <div class="item">
        hello
    </div>
    <div class="item">
        hello
    </div>
</div>

http://runjs.cn/detail/ibxy9qab

ul li:hover{
  border: 1px solid #ed9639;
}

是不是被左边的li挡住了的?最左边的有红边么?

border-left不行吗?

是不是你的选择器 权值太小被覆盖了

hover 的时候 要设置z-index。高于其它层级,这样你的边框才不会被覆盖

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题