Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Div Height

Featured Replies

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.

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.

  • 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.

  • 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.

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.

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 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 by rbrtsmith

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.