制作鼠标移动到div上面显示弹出框
<div class="show-dialog hide"> <header> <div class="note"> <span class="title">三代亲子嘉年华</span> <span class="info"> <span class="username">周乃容</span> <span class="split">|</span> <img src="/resources/img/liveSupport/live/zbbfcs_1.png"> <span class="playcount">3.6万</span> <img src="/resources/img/liveSupport/review/zbpl_1.png"> <span class="viewcount">3562</span> </span> </div> <img src="/resources/img/liveSupport/review/jchgtx_3.png"> </header> <footer> <img src="/resources/img/liveSupport/live/zzzbfm_8.png"> <p>作者唐朝诗人白居易。草原上的野草 生长得很茂盛,每到秋天就枯黄了, 这样年复一年。野火烧得也不可能。</p> </footer> </div>
/*dialog*/ .show-dialog { width: 330px; height: 160px; background-color: #fff; border: 1px solid #CCD0D7; padding: 14px; position: absolute; border-radius: 4px; } .show-dialog>header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid #E5E9EF; } .show-dialog>header>.note>span { display: block; } .show-dialog>header>.note>.title { color: #333; font-size: 16px; } .show-dialog>header>.note>.info { color: #99A2AA; font-size: 12px; display: flex; align-items: center; margin-top: 5px; } .show-dialog>header>.note>.info>.split { padding: 0 10px; } .show-dialog>header>.note>.info>.playcount, .show-dialog>header>.note>.info>.viewcount { padding: 0 25px 0 3px; } .show-dialog>footer { display: flex; align-items: center; margin-top: 10px; } .show-dialog>footer>img { width: 96px; height: 60px; } .show-dialog>footer>p { color: #99A2AA; font-size: 10px; margin-left: 10px; }
$('.default-right>li').hover(function(e) { var position = $(this).offset(); $(".show-dialog").css({ left : position.left, top : position.top - 165 }).removeClass('hide'); }, function(e) { $(".show-dialog").addClass('hide'); });
总结:
1、jquery使用offset()比position()更精确
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
2015-08-31 html5实现全屏的api方法