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

CSS How to Make a Website Styling Web Pages and Navigation Polish the Navigation and Footer

Jeremy Liu
Jeremy Liu
2,137 Points

Page Formatting Questions

Hi guys,

I am having a styling error whenever I resize my browser window. I have the gallery set up just like in the video (with two columns for images). However, I noticed that when the window gets smaller, the paragraphs/captions underneath the images move to separate lines. Example:

"This very long sentence that is inside the <li> element..."

"gets reduced to this when there isn't
enough space"

I noticed that this makes the bottom of certain elements longer than others because there are more lines written. This in turn makes the layout look weird because the larger elements push the other elements into different places creating gaps in the list.

Is there a way to make all of the elements the same size and not be affected by the text?

Maybe instead of moving to the next line, the text looks more like this:

"This very long sentence that is...." (Instead of moving to the next line, it just trails off.)

Alternatively, another solution could be to make the text size smaller as we make the browsing window smaller. Is that possible?

This will help a lot! Thanks! Jeremy

2 Answers

If you want to make the text increase or decrease it size as the window gets smaller or bigger you have to use media queries or you can set the font size in "vw" not "px". The problem is that the "vw'' it doesn't have good browser support. You can set a fixed height for the text container. Or you can set overflow hidden but that will make your text look incomplete.

I think the best way is to use media queries and change the font size based on the resolution or device width

Jeremy Liu
Jeremy Liu
2,137 Points

Awesome, thank you! I'll check out media queries and see what I can do.

Jeremy Liu
Jeremy Liu
2,137 Points

Awesome, thank you! I'll check out media queries and see what I can do.