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

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 :)