使用100%宽度div的滚动条 [英] Scroll bar using 100% width div

查看:296
本文介绍了使用100%宽度div的滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的小提琴: http://jsfiddle.net/34TM4/1/

如您所见,红色 div 的宽度为100%。蓝色 div 的宽度为800像素。如果你滚动到右边,看到800px div的其余部分,你可以看到100%div停止...

As you can see, the red div has a width of 100%. The blue div has a width of 800px. If you scroll to the right, to see the rest of the 800px div, you can see that the 100% div stops...

它设置为100%宽度,但它并不总是不跟随滚动。这是为什么?任何方式使这项工作?

It is set at 100% of width, but it does not always not follow the scrolling. Why is that? Any way to make this work? Using a width of 100% that will always fill 100% of the screen, even if we scroll?

推荐答案

这是因为100%的宽度是100%被定义为元素的父元素的宽度的100%。在这种情况下,因为没有父元素,所以窗口(框架)是父元素。因此,100%将是窗口的宽度,即使其他元素将比窗口的宽度更宽。

That's because 100% is defined as 100% of the width of whatever the element's parent is. In this case, because there's no parent element, the window (frame) is the parent. So 100% will be the width of the window, even if other elements would be wider than the width of the window.

如果你将两个div包装在另一个div,新的容器div的宽度为800px,div的100%将扩展到800像素。

If you wrapped both divs in another div and gave that new container div a width of 800px, the div of 100% would extend to 800 pixels.

这篇关于使用100%宽度div的滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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