将空 div 扩展到页面的长度
我有两个 div 设置为 100 像素,绝对位于页面的左侧和右侧。我在它们之间有一个内容部分。当您从较大页面的顶部滚动到底部时,我希望图像随页面滚动。我的网站共有七个不同大小的页面,我正在尝试使用 CSS 来完成这项工作。谁能帮助我吗?
I have two divs set at 100 pixels absolutely positioned on the left and right sides of the page. I have a content section margined between them. I want the images to scroll with the page as you scroll from top to bottom of the larger pages. There are seven total pages in my site of varying sizes and i am trying to use CSS to make this work. Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看css固定定位。
请参阅此处: http://limpid.nl/lab/css/固定/左侧栏和右侧栏
Look at css fixed positioning.
See here: http://limpid.nl/lab/css/fixed/left-sidebar-and-right-sidebar
这里是一个可能解决您的问题的示例。
它使用背景附件:固定;但您也可以使用位置:固定属性,具体取决于您希望如何使图像在元素中静态或随页面滚动。背景选项的问题是它需要您为其设计背景图像,但它会起作用。
编辑:这里是一篇关于固定定位和跨浏览器兼容性的优秀文章。
Here is an example that might solve your problem.
It uses the background-attachment:fixed; but you could also use the position:fixed attibute depending on how you want to have your images static in an element or scroll with the page. The issue with the background option is it will require you to design a background image for it, but it will work.
EDIT: Here is an excellent post on fixed positioning and cross browser compatibility.
这基本上就是两侧 div 的代码。除了我想要滚动页面长度的背景图像之外,它们完全没有任何内容。
That is basically the code for the two side divs. They are completly void of anything but background images that I want to scroll the length of the page.