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

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

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

clipboard.png

需要修改哪些地方,

阅读 4.3k
1 个回答

红框区域用position: fixed;定位,那个熊用position: absolute;定位,熊是红框的子元素

    .box{
        width: 500px;
        height: 500px;
        border: 1px solid red;
        position: fixed;
        top: 0;
        left: 0;
    }
<div class="box">     //就是在外面加了个box
    <div class="conent">
        <div class="sition">
            <div class="c_header"><strong class="txt">杜绝广告</strong></div>
            <div class="c_adver"></div>
            <i class="sign"></i>
        </div>
    </div>
</div>
var win_width=$(".box").width()-$(".conent").width();/*这里把$(window)换成了$(".box")*/  
var win_height=$(".box").height()-$(".conent").height();/*同上*/
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题