Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Zachary grace
6,682 PointsHelp please.
Ok so I have little to none knowledge of jquery and javascript (Still learning), however I've been told that you can only do what i'm trying to do with it. My issue is that on this website i'm creating each page has different amounts of content in it which makes certain pages longer than other ones and the only way I know how to fix it is setting the main container div height long enough to contain the page with the most content. This makes the pages with very little content look ridiculous. Is there a way to automatically adjust the size of each page?
4 Answers
Adam Moore
21,956 PointsI would suggest using CSS for this, if you can. I'm not completely sure of what the issue is that you are facing, but if you want some white space, but not much, and you want your elements to grow with their contents, then you can use CSS.
Using CSS, when you set the min-height to be a certain height, this means that the element will not be less than that height, but will grow to whatever its contents require. So, if you had a small amount of content on one page, enough to where min-height: 400px would still leave enough white space below the contents, then the height would never go below 400px; however, if your content grows larger than 400px, the element will grow, since its MINIMUM height value is still in tact, with its height growing to greater than 400px (whatever the contents grow to, the element will grow to accommodate them, as well).
Anytime you set a specific height, such as height: 90% or height: 700px, this sets the exact height that the element will be. However, if you give it criteria to follow that is flexible, such as a minimum or maximum height, or even leaving out the height altogether (which will make the element stick with whatever the contents take up, only being as big as the contents), then the element will maintain any height that is within those criteria. So for min-height: 400px, it will never get less than 400px, but it can get infinitely greater because that will mean that it still fits the minimum height criteria set. The same with the max-height: if max-height: 400px, then the element will be anywhere from 0px in height to 400px in height, depending what the contents make it grow to be, since this will fit within the criteria of not be more than the maximum height of 400px.
J Scott Erickson
11,883 PointsYou could set a minimum height so that when you have a small amount of content there is still filler (background or what have you) so that the page takes up the browser window rather than being cut off.
Zachary grace
6,682 PointsHey thanks for the response. The problem is actually that there is too much filler when there is little content and the page just continues on way past the content, not so much that it's being cut off.
Zachary grace
6,682 PointsAdam you are awesome my friend! Thank you! :)
Zachary grace
6,682 PointsAdam you are awesome my friend! Thank you! :)