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.

CSS

stephanie harrison roberts
stephanie harrison roberts
1,713 Points

getting 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&nbsp;&nbsp;&nbsp;&nbsp;<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;

}

The 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.

1 Answer

stephanie harrison roberts
stephanie harrison roberts
1,713 Points

amazing, works perfectly.....thank you very much :)