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.

Problem with website height

Featured Replies

  • Author

100% height always gives me problems. In this case you're probably better off giving the body a negative margin of the value of the top container.

 

Still doesnt work, any other ideas?

The only suggestion I can think of off the top of my head is to make position:relative; top:-100px (your top container height) of your content, and then make any content shown in it have a margin-top of 100px; to clear the header (perhaps you could put an extra "spcaer" invisible div in there at the top measuring the same height as your top div. But it's very clumsy. If you try adding 100px padding to the top of the content, it actually adds it on to the height, so it will always be 100px to high, and therefore clear the bottom of the page by 100px;

I believe there are ways of "calculating" this kind of thng in CSS but they end up pretty hacky.

 

What you're trying to acheive is pretty tricky to come up with an elegant solution for (so far as I know anyway). If anyone has a good one, I'd be interested to read and learn it.

  • Author

The only suggestion I can think of off the top of my head is to make position:relative; top:-100px (your top container height) of your content, and then make any content shown in it have a margin-top of 100px; to clear the header (perhaps you could put an extra "spcaer" invisible div in there at the top measuring the same height as your top div. But it's very clumsy. If you try adding 100px padding to the top of the content, it actually adds it on to the height, so it will always be 100px to high, and therefore clear the bottom of the page by 100px;

I believe there are ways of "calculating" this kind of thng in CSS but they end up pretty hacky.

 

What you're trying to acheive is pretty tricky to come up with an elegant solution for (so far as I know anyway). If anyone has a good one, I'd be interested to read and learn it.

 

Wierd... so basically what is happening is that when i do 100% height on the body div, it actually takes the size from the top of the browser to the bottom and gives it to the div? I tought 100% height makes it stretch to the browser edge and no more. Min-height is the same but it will stretch to fit content right?

 

.....wierd!

Edited by TheGateKeeper

You've got six styles with height: 100% and that is almost certain to cause conflicts.

 

It's often best to let web pages and elements find their own height and not state heights anywhere (not % nor px). You have to consider what happens if you have set height: 100% and someone reduces the window height to less than what your content needs. It may mean that the page or div background "moves up" when you scroll down to see the bottom of the content so that the content seems to stick out from the bottom of the page background color or image.

 

You have a .topPanel 100px high and .mapContainer 500px high, so you could make a page container with min-height: 600px (plus any top or bottom margins, padding and borders) and let the elements flow normally, either one below the other or side by side if floated. However, IE6 doesn't process min-height.

  • Author

You've got six styles with height: 100% and that is almost certain to cause conflicts.

 

It's often best to let web pages and elements find their own height and not state heights anywhere (not % nor px). You have to consider what happens if you have set height: 100% and someone reduces the window height to less than what your content needs. It may mean that the page or div background "moves up" when you scroll down to see the bottom of the content so that the content seems to stick out from the bottom of the page background color or image.

 

You have a .topPanel 100px high and .mapContainer 500px high, so you could make a page container with min-height: 600px (plus any top or bottom margins, padding and borders) and let the elements flow normally, either one below the other or side by side if floated. However, IE6 doesn't process min-height.

 

I understand what you are saying, but i want to make the divs stretch to the bottom of the page. I tried to eliminated the 100%'s like you said by making a container div, and not giving a height to the divs (apart from the header). I was expecting the divs to stretch to the bottom, but they just dissapeared.

 

I dumped it here, what did i do wrong?

 

http://www.themagicfinger.com/test2/map.aspx

 

Thanks!

Wickham is right, letting the content dictate height is the best approach :)

 

However, if it's something that will be of benefit to your visitors, then you'll have to go back to an old method called "faux columns" see the article at http://www.alistapart.com/articles/fauxcolumns/

Your example in your first post doesn't have any backgrounds, so we can't say whether faux columns would work for you, but it might.

 

If you create an image with enough width to cover most browser windows or the width of your page design, by 1px high, comprising different colors across its width, then use repeat-y for the body background style, then it will repeat vertically showing equal height columns of different colors for the full height of the window or of any page height if more than the window height.

 

However, you can't use this method with images that have a pattern or photo, only plain colors, and you can't easily place a border at the bottom unless you put the border on the bottom of the div with most height and then you may find that the border only goes acros that div and not the bottom of a div at the side (perhaps under the div containing your map but not under the sideBar if that has less height).

 

Experiment with the method and see if you can make it work.

  • Author

Your example in your first post doesn't have any backgrounds, so we can't say whether faux columns would work for you, but it might.

 

If you create an image with enough width to cover most browser windows or the width of your page design, by 1px high, comprising different colors across its width, then use repeat-y for the body background style, then it will repeat vertically showing equal height columns of different colors for the full height of the window or of any page height if more than the window height.

 

However, you can't use this method with images that have a pattern or photo, only plain colors, and you can't easily place a border at the bottom unless you put the border on the bottom of the div with most height and then you may find that the border only goes acros that div and not the bottom of a div at the side (perhaps under the div containing your map but not under the sideBar if that has less height).

 

Experiment with the method and see if you can make it work.

 

I cant belive its so complicated to do height:100% hehe. I think i will just give it a fixed height of 1024px!

I cant belive its so complicated to do height:100% hehe. I think i will just give it a fixed height of 1024px!

Web pages were never intended to have a fixed height, that's why it's fiddly to do. What happens if a visitors has their browser font size set to something larger than the default? It would run the risk of spilling over any fixed height blocks you have, and some text may even disappear from view.

 

Don't fight it ;)

  • Author

Web pages were never intended to have a fixed height, that's why it's fiddly to do. What happens if a visitors has their browser font size set to something larger than the default? It would run the risk of spilling over any fixed height blocks you have, and some text may even disappear from view.

 

Don't fight it ;)

 

I fixed it up to make it dynamic :

 

http://www.themagicfinger.com/test2/map.aspx

 

Is it good? The only thing i need to do is make the div "sideBar" go to the bottom regardless of content. Height:100% didnt do anything.

 

Thanks!

You've got another problem at the moment. If you reduce the window size width to about 600px you will see that the sideBar slides over the Map div. Also, if you then scroll to the right to see the remaining azure blocks in the topPanel you see that the black horizontal line stops.

 

This is because the azure blocks and the Map and the sideBar have fixed widths, so you need to make a page container with a fixed width to allow them to stay where you have put them and if you need to scroll, the whole page will move leaving the sideBar at a distance from the right side of the map.

 

Then you can make a background image which is almost all white except for a tiny bit of black where the left side of the sideBar will be, and put it as a faux columns background in the .outerContentContainer with repeat-y and it will go down to the bottom of the outerContentContainer. The sideBar won't need a border-left and will just use as much of the outerContentContainer height as it needs, expanding the outerContentContainer's height and faux columns vertical black line if necessary. outerContentContainer should have the same fixed width as the page container.

Edited by Wickham

  • Author

You've got another problem at the moment. If you reduce the window size width to about 600px you will see that the sideBar slides over the Map div. Also, if you then scroll to the right to see the remaining azure blocks in the topPanel you see that the black horizontal line stops.

 

This is because the azure blocks and the Map and the sideBar have fixed widths, so you need to make a page container with a fixed width to allow them to stay where you have put them and if you need to scroll, the whole page will move leaving the sideBar at a distance from the right side of the map.

 

Then you can make a background image which is almost all white except for a tiny bit of black where the left side of the sideBar will be, and put it as a faux columns background in the .outerContentContainer with repeat-y and it will go down to the bottom of the outerContentContainer. The sideBar won't need a border-left and will just use as much of the outerContentContainer height as it needs, expanding the outerContentContainer's height and faux columns vertical black line if necessary. outerContentContainer should have the same fixed width as the page container.

 

I removes all the width and heights from the divs, but i still have some problems....

 

I tried to explain how i want it to be laid out in this image :

 

explenaton.jpg

 

I want the sideBar to be dynamic so i cant use a background like you said.

 

Hope i can get it to work, its amazing how hard the even the little things can be. I have no problem coding a database or making methods in c# but i havent gotten used to divs and css yet.

 

HALP please! :)

I think you are still trying to mix fluid width for the Inner Content Container with a fixed width for the Sidebar. This will cause problems in a small width window, especially if the Map also has a fixed width.

 

Either everything has to have a fixed width or you could try a totally fluid width page where everything, the Map the containers, the sidebar, the side padding and side margins are all in % widths totalling 100%. However, side borders can't be a % so you have to leave them in px and make the % of all the others total 97% or 98% to allow for the side borders in px.

  • Author

I think you are still trying to mix fluid width for the Inner Content Container with a fixed width for the Sidebar. This will cause problems in a small width window, especially if the Map also has a fixed width.

 

Either everything has to have a fixed width or you could try a totally fluid width page where everything, the Map the containers, the sidebar, the side padding and side margins are all in % widths totalling 100%. However, side borders can't be a % so you have to leave them in px and make the % of all the others total 97% or 98% to allow for the side borders in px.

 

What do you mean fixed width? Everything below the top bar is dynamic. But i cant get it to work like the picture.

 

The main problem is that the InnerContainer doesnt stretch fully even thou it should.

 

I want to reproduce what i explained in the image.... is it clear from the image how i want it?

Edited by TheGateKeeper

  • Author

What do you mean fixed width? Everything below the top bar is dynamic. But i cant get it to work like the picture.

 

The main problem is that the InnerContainer doesnt stretch fully even thou it should.

 

I want to reproduce what i explained in the image.... is it clear from the image how i want it?

 

Bump.. i cant get it to work.

Here's something for you to look at:-

http://www.wickham43.com/forumposts/thegate110622.html

The page valdates but doesn't do everything you want. If you reduce the window width you will see the lime spaces in .outerContentContainer beside .innerContentContainer (teal) enclosing the map (skyblue) reduce to zero.

 

I had to make a min-width for the containers because you have a sidebar 168px and a map 500px wide and I assume that any less width than what can show them side by side would be no good (.sideBar would either go down below or slide over the left side).

 

Height: 100% for the .outerContentContainer and .sideBar is difficult, so I coded it so that the sidebar can have as much content as you want and the left side #wrap (yellow) will get dragged down to the same level. The div .sideBar must always have the most content.

 

If you use the same background for #wrap (yellow) as .outerContentContainer (lime) then the left side divs will appear to go down as far as .sideBar without a change of background and this may help if you have a little content below the map (but not so much that it exceeds the .sideBar height).

 

IE6 doesn't process min-width or min-height so I've put in a conditional comment with fixed sizes for IE6.

Edited by Wickham

  • Author

Here's something for you to look at:-

http://www.wickham43.com/forumposts/thegate110622.html

The page valdates but doesn't do everything you want. If you reduce the window width you will see the lime spaces in .outerContentContainer beside .innerContentContainer (teal) enclosing the map (skyblue) reduce to zero.

 

Isnt it working as intended if the lime space is reduced to 0 after resize? I mean, the whole reason its there is to provide padding.

 

I had to make a min-width for the containers because you have a sidebar 168px and a map 500px wide and I assume that any less width than what can show them side by side would be no good (.sideBar would either go down below or slide over the left side).

 

The idea is good, but i was planning on putting more than the map in the border box. Isnt it possible to make it stretch to the content in it while keeping it from being smaller than the actual content? Sort of like how it works, but dynamic.

 

Height: 100% for the .outerContentContainer and .sideBar is difficult, so I coded it so that the sidebar can have as much content as you want and the left side #wrap (yellow) will get dragged down to the same level. The div .sideBar must always have the most content.

 

How exactly does height:100% work? Doesnt it simply take the height of the parent div? If it isnt possible to make the div stretch to the bottom of the screen, is it not atleast possible to make it stretch to the content in it? Like display Table?

 

If you use the same background for #wrap (yellow) as .outerContentContainer (lime) then the left side divs will appear to go down as far as .sideBar without a change of background and this may help if you have a little content below the map (but not so much that it exceeds the .sideBar height).

 

IE6 doesn't process min-width or min-height so I've put in a conditional comment with fixed sizes for IE6.

 

Im not at home right now so i cant look at the actual code, but it looks like it could work with some adjustments?

One thing i wanted to ask... in my previous posts you said it was better not to use fixed dimensions as it can break the page, but in your implementation you used it a lot, so i guess this layout cant be 100 dynamic?

 

Thanks!

I said it's better not to use fixed sizes for HEIGHT, just let an element find its own height. I have used a fixed height for the .topPanel and .mapContainer as I assume that the content will be a map image with a fixed height and perhaps a logo image in the .topPanel. You could delete the height for .topPanel but as there is only one word of content at the moment it would collapse in height, so when testing a page structure before adding content you may have to add height temporarily.

 

It's also not a good idea to mix fixed widths with % widths.

  • Author

I said it's better not to use fixed sizes for HEIGHT, just let an element find its own height. I have used a fixed height for the .topPanel and .mapContainer as I assume that the content will be a map image with a fixed height and perhaps a logo image in the .topPanel. You could delete the height for .topPanel but as there is only one word of content at the moment it would collapse in height, so when testing a page structure before adding content you may have to add height temporarily.

 

It's also not a good idea to mix fixed widths with % widths.

 

what about the part i said about the sidebar? You gave that a fixed height too right? Can i make it stretch to content?

The .sidBar has min-height and will stretch to any height (I showed three p tags with large margin-top to demonstrate this).

  • Author

The .sidBar has min-height and will stretch to any height (I showed three p tags with large margin-top to demonstrate this).

 

http://www.themagicfinger.com/test2/map.aspx

 

Here is my implementation based on your suggestions.

 

It works, but when i resize the windows the side bar overlaps the border box. Is this because i didn't give the border box any width? I did this because i want to put different content in the box... and thus the adjacent elements should stretch to it.

 

Thanks bro... one last problem and its done!

I think you've just got the min-widths calculated wrong, When I reduce the window width the sideBar does stop, but not until it's passed over the map.

 

Also there's something else wrong because the black horizontal line stops when you scroll right in a small window, whereas it doesn't in my version, so look carefully at what you changed from my code.

  • Author

I think you've just got the min-widths calculated wrong, When I reduce the window width the sideBar does stop, but not until it's passed over the map.

 

Also there's something else wrong because the black horizontal line stops when you scroll right in a small window, whereas it doesn't in my version, so look carefully at what you changed from my code.

 

Ok, i fixed it.

 

http://www.themagicfinger.com/test2/map.aspx

 

Some points:

 

-I removed the inner container because in my implementation it was never needed. It wasn't needed because the top menu will always be bigger than the content below, so it will never be "crushed". Is it correct that i removed it? In yours it wasn't needed either (it was called outerContentContainer) for the same reason.

 

-Even thou it works, i still have problems with the side bar. If i change the map image to an image that is taller than the sidebar, the sidebar wont stretch to the image's new, bigger height. I cant find a solution to this. I could use faux columns, but id rather not. Is that the only way?

 

Thanks!

In your original page you had a fixed height for the map, so I used that 500px height and made the sideBar a min-height that was equal to the map container div, so that the sideBar would always be equal but could be more height than the map. Now you say you want the map div to be more than 500px, you could adjust the sideBar min-height to suit it.

 

You could try this tutorial where any column can have the most height

http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks

but I'm not sure if it will work with flexible min-width.

 

Faux columns needs a fixed width so you probably can't use that either.

 

My version expanded and contracted within limits so the sideBar starts at the right side in a large width window and moves close to the map container in a smaller width window but your version doesn't do that.

  • Author

In your original page you had a fixed height for the map, so I used that 500px height and made the sideBar a min-height that was equal to the map container div, so that the sideBar would always be equal but could be more height than the map. Now you say you want the map div to be more than 500px, you could adjust the sideBar min-height to suit it.

 

Yes my original design was flawed but i expressed that the map part was actually going to keep the content of many things. Its a game if you havent noticed so fights and stuff will always be in the border. It doesnt matter if it doesnt have much headroom to grow width wise but height was it has to be dynamic.

 

You could try this tutorial where any column can have the most height

http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks

but I'm not sure if it will work with flexible min-width.

 

Faux columns needs a fixed width so you probably can't use that either.

 

Maybe i dont understand faux columns, but wouldnt it work with just a set width for the sidebar? You could make the image to be as small as the screen can be at any given time and make it start from the right side of the screen.

 

My version expanded and contracted within limits so the sideBar starts at the right side in a large width window and moves close to the map container in a smaller width window but your version doesn't do that.

 

My version doesnt do that because i didnt want the menu up top to get hidden. Your didnt have any menu items, thats why it was able to get so small :)

 

 

Will try it later, going out now!

 

Thanks

Edited by TheGateKeeper

  • Author

I looked at that tutorial and i see no way of how i can implement it in my design :(.

 

Anyway, i tried with faux and got it to work, but i still have one small thing i cant do. The sidebar now properly stretches to the content, but i cant get the outerContainer to wrap around the sidebar.

 

Here, i uploaded 2 versions with a different image in the map container to show what i mean:

 

http://www.themagicfinger.com/test1/map.aspx

http://www.themagicfinger.com/test2/map.aspx

 

Just this bit and it works :)

  • Author

I looked at that tutorial and i see no way of how i can implement it in my design :(.

 

Anyway, i tried with faux and got it to work, but i still have one small thing i cant do. The sidebar now properly stretches to the content, but i cant get the outerContainer to wrap around the sidebar.

 

Here, i uploaded 2 versions with a different image in the map container to show what i mean:

 

http://www.themagicfinger.com/test1/map.aspx

http://www.themagicfinger.com/test2/map.aspx

 

Just this bit and it works :)

 

Bump

Guest
This topic is now closed to further replies.

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.