首页 > 其他 > 详细

----关于posotion的

时间:2018-10-13 15:22:02      阅读:223      评论:0      收藏:0      [点我收藏+]

sticky

出现在正常流当中,不能设置定位,随页面滚动

(sticky = relative + fixed)

 

fixed

不出现在正常流当中,能设置定位,随页面滚动

 

eg:

html:

  <p>
    <div class="box" id="one">One</div>
    <div class="box" id="two1">Two1</div>
    <div class="box" id="three">Three</div>
    <div class="box" id="four">Four</div><br><br><br><br>
  </p><p>
    <div class="box" id="one">One</div>
    <div class="box" id="two2">Two2</div>
    <div class="box" id="three">Three</div>
    <div class="box" id="four">Four</div><br><br><br><br>
  </p>

 

css:

  #two2 {
    position: sticky;
    top: 20px;
    left: 20px;
    background: #168989;
    }


  #two1 {
    position: fixed;
    top: 20px;
    left: 20px;
    background: #452589;
    }

效果如图:

(Two1为sticky,Two2位fixed)

技术分享图片

当页面向下滑动时,效果如下:

技术分享图片

 

----关于posotion的

原文:https://www.cnblogs.com/player-yenney/p/9782925.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!