大佬教程收集整理的这篇文章主要介绍了html – 悬停边框位置,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试过使用绝对位置和线高,但无法取得多大成功.
这就是我想要的:
这是代码:
HTML:
<div class="box"> <ul> <li><a href="#">test 1</a></li> <li><a href="#">test 2</a></li> </ul> </div>
CSS:
ul{ list-style: none; padding: 0 0 10px; margin: 0; border-bottom: 5px solid green; overflow: hidden; } ul li{ float: left; margin-left: 20px; } a{ text-decoration: none; display: block; } a:hover{ border-bottom: 5px solid red; }
使用以下CSS:
ul { list-style: none; margin: 0; border-bottom: 5px solid green; position:relative; padding:0; } ul li { padding:10px 10px; margin-left: 20px; display:inline-block; position:relative; bottom:-5px; /* <-- offset bottom of li by border width so it overlaps ul green border */ border-bottom: 5px solid transparent; /* add border,make transparent so it doesnt 'jump' on hover */ } a { text-decoration: none; display: block; } li:hover { border-color:red; /* <-- use the li hover event (not a hover) to color the border */ }
以上是大佬教程为你收集整理的html – 悬停边框位置全部内容,希望文章能够帮你解决html – 悬停边框位置所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。