简体   繁体   English

固定 div 为 100% 高度的实心

[英]Fixed div as solid with 100% height

I'm trying to go with the css-only approach to this issue and not to use margin-left to move the <div class="fd"></div> from <div class="sb"></div> I've ran out of the idea-fuel what to try.我正在尝试使用 css-only 方法来解决这个问题,而不是使用margin-left<div class="sb"></div>移动<div class="fd"></div> <div class="sb"></div>我已经没有想法了——燃料尝试什么。 I've nested some wrappers and used different kinds of positionings (this is not a typo nor French, spell-checker excuse me) but nothing has worked out so far.我嵌套了一些包装器并使用了不同类型的定位(这不是拼写错误,也不是法语,请原谅我是拼写检查器),但到目前为止还没有解决。

Issue: Making a fixed div as solid element, to accept the .fd element on it's right side.问题:将固定 div 制作为实体元素,以接受其右侧的.fd元素。

.fd holds content which is going to exceed the height of the page. .fd保存将超过页面高度的内容。
.sb holds side-content which is going to remain as 100% in height. .sb包含将保持 100% 高度的副内容。

See snippet for a clear example what I've been struggling with.有关我一直在努力的清晰示例,请参阅片段。

 * { margin: 0; padding: 0; box-sizing: border-box; } .sb { height: 100%; width: 300px; background: blue; position: fixed; opacity: 0.5; } .fd { min-height: 100%; background-color: red; display: inline; /* Won't apply to fixed? block will overlap everything */ }
 <div class="sb"></div> <div class="fd"> <p>Am I out in the open?</p> </div>

Added an extra .wrap .添加了一个额外的.wrap

 * { margin: 0; padding: 0; box-sizing: border-box; } .wrap{ padding-left: 300px; } .sb { height: 100%; width: 300px; background: blue; margin-left: -300px; position: fixed; opacity: 0.5; } .fd { min-height: 100%; background-color: red; display: inline; /* Won't apply to fixed? block will overlap everything */ }
 <div class="wrap" id="wrap"> <div class="sb"></div> <div class="fd"> <p>Am I out in the open?</p> </div> </div>

https://jsfiddle.net/afelixj/tb3pbam9/ https://jsfiddle.net/afelixj/tb3pbam9/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM