css如何实现广告固定动态漂浮

http://sc.chinaz.com/jiaobendemo.aspx?downloadid=201590051448

以上代码是浏览器全屏的漂浮,如图所示,我怎么让他跟随浏览器并固定在红框区域里面漂浮,

https://img4.mukewang.com/5c4035cf00019f3908000394.jpg

需要修改哪些地方,

慕桂英3389331
浏览 954回答 1
1回答

隔江千里

红框区域用position: fixed;定位,那个熊用position: absolute;定位,熊是红框的子元素&nbsp; &nbsp; .box{&nbsp; &nbsp; &nbsp; &nbsp; width: 500px;&nbsp; &nbsp; &nbsp; &nbsp; height: 500px;&nbsp; &nbsp; &nbsp; &nbsp; border: 1px solid red;&nbsp; &nbsp; &nbsp; &nbsp; position: fixed;&nbsp; &nbsp; &nbsp; &nbsp; top: 0;&nbsp; &nbsp; &nbsp; &nbsp; left: 0;&nbsp; &nbsp; }<div class="box">&nbsp; &nbsp; &nbsp;//就是在外面加了个box&nbsp; &nbsp; <div class="conent">&nbsp; &nbsp; &nbsp; &nbsp; <div class="sition">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="c_header"><strong class="txt">杜绝广告</strong></div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="c_adver"></div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <i class="sign"></i>&nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; </div></div>var win_width=$(".box").width()-$(".conent").width();/*这里把$(window)换成了$(".box")*/&nbsp;&nbsp;var win_height=$(".box").height()-$(".conent").height();/*同上*/
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript