div层位于右侧并悬浮随窗口移动,相对固定

2021年3月25日14:52:54 发表评论
广告也精彩

<div id="rel_div" style="width:400px; z-index:100px; position:absolute; right:20px; float:right; background:#eea; ">

float:right;

层位于右侧

 

position:absolute; right:20px; top:20px;

这样是相对固定的。

 

z-index:100px;

层级于上层。

 

JS jquery 调用,随鼠标移动,层跟着移动。

$("#rel_div").css("top", $(document).scrollTop()+20 );//将滚动条高度赋给悬浮框。

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
ts小陈

发表评论(请规范评论)--评论需审核

:?: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :cry: :mrgreen: :neutral: :razz:

已登录用户不需要填写以下内容