div固定显示的几种方法
很多时候我们会受到一些需求: 1、div一直置顶 2、div一直置底 3、超过一定的位置之后div置顶 4、超过一定位置之后div置底 那么下面针对上面的几个问题写几个案例: 一、div一直在屏幕的上方,这个倒是容易咱们直接使用position:fixed;然后设置他的top值和left就可以了,别忘了设置宽度哦 <div class="top"> <div class="topf">跟单</div> </div> <style> .top,.topf{ height:100px; width:100%;} .topf{ position:fixed; top:0; left:0; background:#999; text-align:center; font-size:20px; color:#fff;} </style> 点击这里查看demo -》 二、这个跟上面的例子是一样的,我不不多说了 <div class="bottom"> <div class="bottomf">跟单</div> </div> <style> .bottom,.bottomf{ height:100px; width:100%;} .bottomf{ position:fixed; bottom:0; left:0; z-index:12; background:#999; text-align