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 trialMahmoud Amin
Courses Plus Student 6,269 PointsImage's background
For this code:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Images' gallery</title> <link href="style.css" rel="stylesheet"> <style> ul li { list-style:none; float:left; width:23%; margin:1%; background:lightgrey; color:darkgrey; } </style> </head>
<body> <div id="gallery">
<ul>
<li><a href="1.jpg"><img src="1.jpg" alt="1"></a>
<p>The first photo image</p></li>
<li><a href="2.jpg"><img src="2.jpg" alt="2"></a>
<p>The second photo image</p></li>
<li><a href="3.jpg"><img src="3.jpg" alt="3"></a>
<p>The third photo image</p></li>
<li><a href="4.jpg"><img src="4.jpg" alt="4"></a>
<p>The forht photo image</p></li>
<li><a href="5.jpg"><img src="5.jpg" alt="5"></a>
<p>The fifth photo image</p></li>
</ul>
</div>
</body> </html>
Firstly their is a variance between each image and relative background in terms of height and width
and the float property is only applied to the background i.e. when i shrink the page then the images overlap while the background strict to their margins
So i just wanna know why does this issue happening and how to fix it
Thanks :)
Mahmoud Amin
Courses Plus Student 6,269 PointsOpen the folder named images that contains the code, the style and the images themselves.
Thanks for the instructions and help :)
1 Answer
Patrick Tse
10,682 PointsYou probably want to apply the style to [#gallery li] instead of [#gallery ul li a].
Do you want it to look like this snapshot? https://w.trhou.se/g42nt3yyl7
Steven Parker
231,269 PointsSteven Parker
231,269 PointsSince your issue involves images, we probably need to see those also.
Make a snapshot of your workspace and post the link to it here.