Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

stephanie harrison roberts
1,713 Pointsgetting an image to automatically fill its container
morning all, i have this image and a div container and cant get it to fill the container 100% could someone help out?
thanks steph
<html>
<head class="main-head">
<title>Coding Mama</title>
<!--/*title is what shows in the top tab*/-->
<link rel="stylesheet" href="codingoverbreakfast.css">
<meta name="description"
content="A general guide on the use of meta tags in html pages">
<!--/*meta tags are information about the site, we use there fo search engine purposes*/-->
</head>
<body>
<div class="topnav">
<a class="active" href="#home">Home</a><br>
<a href="#About">About</a><br>
<a href="#contact">Contact</a><br>
<a href="#classes">Classes</a><br>
</div>
<h1>CODING <span>Mama</span></h1>
<div class="heroshot">
<img src="lights.jpg" class="lights">
</div>
</body>
</html>
.lights{
max-width: 100%;
max-height: 100%;
background-repeat: no-repeat;
}
1 Answer

stephanie harrison roberts
1,713 Pointsamazing, works perfectly.....thank you very much :)
Edgars M
2,019 PointsEdgars M
2,019 PointsThe problem here is max-width and max-height styles. These 2 ensure that your image will not exceed the size of its parent. If you want to make image the size of its container just remove 'max-' from both style elements.