div具有固定位置 [英] div with fixed position

查看:114
本文介绍了div具有固定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div与样式位置:固定,我想要向下滚动页面,但我不想要的div溢出页脚。

解决方案



  body 

html {height:100%; margin:0; padding:0} / * margin和padding 0 for firefox * /
.mainBody {height:90%; overflow:auto;}

HTML

 < div style =border:1px solid black;> TOP< / div> 
< div class =mainBody>
< div style =height:800px;>< / div> <! - To for scroll - >
这里是主体
< / div>

这会将滚动条从窗口移动到显示内容的div。
TOP div会留在你想要它的位置,所以你可以放置它aboslutely或保持原样,并且它不会与你的页脚碰撞,你可以放在你的主体div。


I have a div with style position:fixed and i want it to scroll down the page, but i don't want the div to spill into the page footer. How could i accomplish this?

thanks in advance, shawn

解决方案

Try this.

CSS

body, html {height:100%;margin:0;padding:0} /* margin and padding 0 for firefox*/
.mainBody {height:90%;overflow:auto;}

HTML

  <div style="border:1px solid black;">TOP</div>
  <div class="mainBody">
      <div style="height:800px;"></div> <!-- To for scroll -->
      HERE IS Main Body
  </div>

This will transfer the scroll bars from the window, to the div that is showing your content. The TOP div will stay put where ever you want it, so you can position it aboslutely or leave it as is, and have it never collide with your footer, which you can put in your main body div.

这篇关于div具有固定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆