简体   繁体   English

如何使边框跟随网页顶部导航栏中的cursor

[英]How to make border follow the cursor in the top navigation bar on a webpage

I have a question.我有个问题。 I am making a webpage and I got an idea that the top navigation bar would follow my cursor.我正在制作一个网页,我知道顶部导航栏将跟随我的 cursor。 Basically, I would like that the border around each link in the top bar would follow where I move my mouse cursor.基本上,我希望顶部栏中每个链接周围的边框会跟随我移动鼠标 cursor 的位置。 I got this idea from iOS (specifically from photos) that has a lot of these cool features.我从 iOS(特别是来自照片)那里得到了这个想法,它有很多很酷的功能。 Any idea how to accomplish this?知道如何做到这一点吗?

I am also providing you with a link to google drive where I posted the video because as I know you currently can't upload the video directly here.我还为您提供了一个指向我发布视频的谷歌驱动器的链接,因为据我所知,您目前无法直接在此处上传视频。

https://drive.google.com/file/d/17nqIWUtp0Smr4I8RzWJDahjYioLxtwdQ/view?usp=sharing https://drive.google.com/file/d/17nqIWUtp0Smr4I8RzWJDahjYioLxtwdQ/view?usp=sharing

Any help will be very appreciated.任何帮助将不胜感激。

Sorry, not very adaptative.对不起,不是很适应。 Can't think about something better right now:现在想不出更好的办法:

 body { font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; background: #000; padding:20px; margin:0; } div { background: #333; border-radius: 30px; overflow:hidden; padding:0 5px; position: relative; font-size:0; display:inline-block }.highlight { display: block; width: 100%; background: #ccc; position: absolute; height: calc(100% - 10px); top: calc(50%); transform: translateY(-50%); left: -100%; border-radius: 30px; transition: left.2s ease, width.2s ease; pointer-events: none; margin-left: 6px; width:0; opacity: 0; } a { display: inline-block; font-size: 12px; text-decoration: none; color: #FFF; padding: 10px; margin: 4px 0; z-index: 999; position:relative; transition: color 0.2s; } a:hover { color: #000 } a:hover ~.highlight { opacity: 1; } a:nth-of-type(1):hover ~.highlight { left: 0px; width: 39px; } a:nth-of-type(2):hover ~.highlight { width: 42px; left: 50px; } a:nth-of-type(3):hover ~.highlight { left: 104px; width: 35px; } a:nth-of-type(4):hover ~.highlight { left: 152px; width: 59px; }
 <div> <a href="#">Years</a> <a href="#">Month</a> <a href="#">Days</a> <a href="#">All photos</a> <div class="highlight"></div> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM