[英]Inner div width/height to 100% body size not parent div with side JS
I have a base layer on top of which I have more multiple layers. 我有一个基础层,我有更多的多层。 On my second layer, I want its width to stretch out to the width of the body.
在我的第二层,我希望它的宽度伸展到身体的宽度。
Main Project: 主要项目:
http://jsfiddle.net/ygXy6/694/ http://jsfiddle.net/ygXy6/694/
What I've tried: 我尝试过的:
I searched into: Make div inside parent 100% width of body, not parent div 我搜索到: 在父亲的100%宽度内进行div,而不是父div
This Does work: http://jsfiddle.net/ygXy6/18/ 这确实有效: http : //jsfiddle.net/ygXy6/18/
But doesn't work with my project, probably due to my parallax
JS, this is my outcome when I apply the above method: https://jsfiddle.net/epkevxps/ 但是对我的项目不起作用,可能是由于我的
parallax
JS,这是我应用上述方法时的结果: https : //jsfiddle.net/epkevxps/
I also tried using vw
as one of the width units which leads me to think that i need to change my JS rather than CSS 我也尝试使用
vw
作为宽度单位之一,这让我觉得我需要改变我的JS而不是CSS
My desired outcome would be for layer two to be 100% in width and layer three at 100% height: like this static example 我希望的结果是第二层的宽度为100%,第三层的高度为100%: 就像这个静态的例子
https://jsfiddle.net/mcxwnwy3/ https://jsfiddle.net/mcxwnwy3/
I suggest you start fiddling with vh
and vw
. 我建议你开始摆弄
vh
和vw
。 A better solution would be to make all elements siblings and use the z-index
property instead of nesting them. 一个更好的解决方案是使所有元素兄弟姐妹使用
z-index
属性而不是嵌套它们。 That way you can use % for all elements. 这样你可以使用%来表示所有元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.