How to overlay div / box on mouseover?

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

I have a link and when user hover mouse over it, it should display a box (div) under the link. The box should overlay whatever is under it. How can I do it using css or javascript?

回答1:

I have created a sample here. You can modify from there to suit your needs.



回答2:

You have an absolutely positioned div that is hidden, and a child of the link. Then, when you hover over the link, you should unhide the div. I can't provide full CSS, and I haven't tested this, but that should get you started. You'll have to play around with the positioning and sizes.

<a href="#" class="special">Somewhere<div class="desc">This is hidden.</div></a>  a.special { position:relative; } a.special div.desc { background-color:white; display:none; position:absolute; z-index:100; } a.special:hover div.desc { display:block; } 

This would be the pure-CSS way.



回答3:

$("#id").mouseover(function(){    $("a[rel='#petrol']").overlay().load(); }); $("#id").mouseout(function(){    $("a[rel='#petrol']").overlay().close(); }); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!