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

A note regarding the container div class

I noticed that a number of people are having issues with <div class="container> in the Grids section. I myself threw myself at the same problem for an hour. Turns out there was nothing wrong with my code. I'm running two monitors, one 16:9 high-resolution monitor for working and a smaller 15" monitor for web searches, music, etc.

I was running my tests on the smaller monitor and couldn't figure out why my margins weren't showing up. But then I tried running the page in the larger monitor, and low and behold, my margins showed up. I don't know if this will maybe help anyone, or if someone wants to shed some light on this.

I'm thinking that the issue is the [margin: auto;] part. I switched the 'auto' part to '10%' and it worked, albeit with the addition of a scroll bar. Your page will also not be centered, but you'll at least know if your code is working.

1 Answer

Nachiket Kumar
Nachiket Kumar
3,590 Points

I'm not sure which exercise this is referencing, but if you give your .container a max-width that is less than your minimum browser width under normal use (say, 1000px), you can still use margin: 0 auto;. This will center the div. You would need to adjust for different viewport sizes, and this might affect your other styles as I don't know the details of your code.

Under your previous experience, if margins weren't showing up on the smaller lower res monitor, were you getting a horizontal scroll bar? If you scrolled all the way to either side, were you able to see the margins?