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
Shaun Moore
6,301 PointsHow to make CSS not overlap
So I have a block of code (PHP) and it can change in size depending on what the item is, now when its bigger the DIV it's in is too small and the text overlaps so how can I make it so the DIV is the same size as the text? :-)
Thanks :D
1 Answer
Codin - Codesmite
8,600 PointsSet the height of the div to auto so that it sizes itself based on the size of its child elements.
height: auto;
Example (The Red Div on the left is set to 100px height and the Green Div on the right is set to auto height):
Shaun Moore
6,301 PointsShaun Moore
6,301 PointsThanks! I thought about using this but I was like its not going to work haha, thank you!