How to overlay div / box on mouseover?

前端 未结 3 2242
借酒劲吻你
借酒劲吻你 2021-02-15 11:14

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 javascri

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-15 11:53

    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.

    Somewhere
    This is hidden.
    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.

提交回复
热议问题