June 7, 20188 yr I have a div that I have the height set to 100%. It does not fill the container to 100%. What have I done wrong?
June 8, 20188 yr It won't fill the height of the container unless the container has it's own height property explicitly set.
June 8, 20188 yr If you don't know the height of the container or it is a product of it's children (dynamic content) then you can do something like this. .container { position: relative; } .container__child { position: absolute; top: 0; right: 0; bottom: 0; left: 0; } This will cause it to overlay the container and match it's dimensions.
June 9, 20188 yr 10 hours ago, gigman7 said: That didn't work. You're going to have to give us more to go off than that if you want this solving. I suggested two ways that definitely do work so something must be incorrect in your implementation.
June 9, 20188 yr Author I have been told that there is no way to do it. What it is doing when I set the height to 100% is set the height to the height of the monitor.
June 9, 20188 yr Author If I have .elem-a as my parent div that each page has a different amount of content and will be a different height depending on the amount of content. And I have .elem-b as the child div that I set the height:100%; then why does it not fill the parent div 100%. I can understand that if the parent has a padding: 10px; and it not filling that padding, but if the parent div is longer then the height of the monitor then the child div will only reach the height of the monitor. I have the child div set float:left and at the bottom of the child div, the content in the parent div will justify to the left below the child div.
June 9, 20188 yr 1 hour ago, gigman7 said: I have been told that there is no way to do it. What it is doing when I set the height to 100% is set the height to the height of the monitor. Going off what you have said so far then you have been advised wrong. It is possible.
June 9, 20188 yr Is this what you mean? https://codepen.io/anon/pen/mKRRYv Also if you want to set heights relative to that of the viewport then you can use viewport units `100vh` will ensure the element's height matches that of the viewport.
June 9, 20188 yr Author https://codepen.io/glennbates/pen/JZEybZ I want the blue side div to go from top to bottom. I have it set to 100% so why doesn't it fill 100%? Edited June 9, 20188 yr by gigman7
June 9, 20188 yr It might be beneficial to produce the layout you are looking for graphically, in something like Photoshop/GIMP/Paint. Because at the moment I am not fully understanding what it is you want to achieve. If you can show me the structure you'd like, I'd gladly mock something up. Off the top of my head, if you want divs side-by-side with equal height, Flexbox is the way to go.
June 11, 20188 yr You mean like this? https://codepen.io/anon/pen/zaZBPq This mirrors what I suggested earlier - giving the parent nodes explicit heights. I should add there's a lot of things like magic numbers in this code. I advise you to read through this article to avoid things like that in your CSS https://csswizardry.com/2012/11/code-smells-in-css/ Edited June 11, 20188 yr by rbrtsmith
June 11, 20188 yr On 6/9/2018 at 11:53 PM, Fee said: It might be beneficial to produce the layout you are looking for graphically, in something like Photoshop/GIMP/Paint. Because at the moment I am not fully understanding what it is you want to achieve. If you can show me the structure you'd like, I'd gladly mock something up. Off the top of my head, if you want divs side-by-side with equal height, Flexbox is the way to go. You don't need flexbox for this. While flexbox is useful it shouldn't be used for full-page layout as you introduce the risk of layout thrashing - which is not ideal if your content is dynamic.https://jakearchibald.com/2014/dont-use-flexbox-for-page-layout/
Create an account or sign in to comment