
这是我的SASS
body,HTML { wIDth: 100%; height: 100%; padding: 0; margin: 0;}#neo_wrapper { wIDth: 960px; height: 1500px; margin: 0 auto; #neo_main_container1 { /* SlIDe1 container */ wIDth: 100%; height: 100%; margin: 0 auto; background: #999999; z-index: 350; #neo_scroll_button { /* div that enables scroll */ position: absolute; bottom: 35px; left: 0; right: 0; margin: 0 auto; wIDth: 150px; height: 15px; background: #F00; color: #FFF; text-align: center; line-height: 15px; display: table; a { &:link {text-decoration: none; color: #FFF;} &:visited {text-decoration: none; color: #FFF;} } } } #neo_main_container2 { wIDth: 100%; height: 100%; margin: 0 auto; background: #CCC; z-index: 300; #neo_img_container { float: left; wIDth: 350px; height: 500px; margin: 0 auto; margin-right: 15px; } #neo_text_container { float: left; wIDth: 50%; height: 500px; margin: 0 auto; } } } 和HTML
<body><div ID="neo_wrapper"> <div ID="neo_main_container1"> <!-- Start container1 --> <div ID="neo_scroll_button" onClick="scrollBelow()"> <p>Enter</p> </div> </div> <!-- End of container1 --> <div ID="neo_main_container2"> <!-- Start container2 --> <div ID="neo_img_container"> <img src="http://fpoimagery.com/?t=px&w=350&h=250&bg=0ff&fg=000000" /> </div> <div ID="neo_text_container"> <p>Lorem ipsum dolor sit amet,consectetur adipisicing elit,sed do eiusmod tempor incIDIDunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupIDatat non proIDent,sunt in culpa qui officia deserunt mollit anim ID est laborum.</p> </div> </div> <!-- End container2 --></div>
我希望#neo_main_container1成为屏幕的全宽.显然因为它是#neo_wrapper的孩子,将宽度设置为100%将使其成为960px.我确定如何规避这个问题,所以任何帮助都会受到赞赏.
更新:这是我的Js小提琴:http://jsfiddle.net/VkqjH/
解决方法 您可以使用新单位:vw – 视口宽度
vh – 视口高度
#neo_main_container1{ wIDth: 100%; //fallback wIDth: 100vw;} Help/MDN
Opera Mini不支持此功能,但您可以在所有其他现代浏览器中使用它.
CanIUse
总结以上是内存溢出为你收集整理的html – 使div为浏览器窗口的100%宽度全部内容,希望文章能够帮你解决html – 使div为浏览器窗口的100%宽度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)