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
Idan shami
13,251 Pointshow to place text beneath my photos? + how to position photos on my text
this is my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Protfolio</title>
<link rel="stylesheet" href="D:/coding/style.css">
</head>
<body>
<div class="container">
<div class="header">
<img src="bigcloud.png" alt="bigcloud" class="bigcloud">
<div class="list">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Me</a></li>
</ul>
</div>
</div>
<div class="title">Gallery</div>
<div class="first3 clearfix">
<img src="sakura2.jpg.jpg" alt="sakura full body" class="img1">
<img src="sakura.jpg.jpg" alt="sakura face" class="img1">
<img src="sensi.jpg.jpg" alt="dragonballsensi" class="img1">
<img src="the meeting.jpg" alt="gandalf and dumbledore" class="img1">
<img src="naruto2.jpg.jpg" alt="naruto teachers" class="img1">
<img src="naruto.jpg.jpg" alt="naurto" class="img1">
</div>
</div>
<footer class="clearfix">
<p>
All the art is mine, and protected by copyrights.
</p>
<div id="sociallogos">
<img src="instagram.png" alt="instagram logo" class="socialmedia">
<img src="facebook.png" alt="facebook logo" class="socialmedia">
<img src="twitter.png" alt="twitter logo" class="socialmedia">
</div>
</footer>
</body>
</html>
body {
font-family: Comic sans MS;
margin: 0;
}
.list ul {
list-style: none;
}
.list li {
display: inline-block;
font-size: 1.8em;
margin: 0 5em;
margin-bottom: 0.5em
}
.header {
background-color: #39f;
margin-top: 0;
box-sizing: border-box;
box-shadow: 0.3em 0.3em 4em #ccc;
background: linear-gradient(#39f, #3cf)
}
a {
text-decoration: none;
color: #036;
}
.title {
color: #3cf;
font-size: 2.5em;
padding-top: 1.5em;
padding-left: 2em;
padding-bottom: 1em;
border-bottom: 1px solid #39f;
}
footer {
background-color: #369;
padding: 1em;
margin-top: 1em;
border-top: 1px solid #39f;
}
footer p {
padding-bottom: 0.2em;
display: inline-block;
}
/* pics */
.bigcloud {
display: block;
margin-left: 32%;
margin-right: 10%;
height: 50px;
}
.first3 {
margin: 1em 0 1em 5em;
display: inline-block;
}
.img1 {
height: 250px;
width: 367.91px;
margin: 1em 2.8em;
border-radius: 0.625em;
box-shadow: 0.3em 0.3em 0.9em grey;
}
.socialmedia {
height: 1.8em;
padding-left: 1em;
padding-top: 2em;
}
#sociallogos {
float: right;
position: relative;
bottom: 17px;
display: inline-block;
}
.clearfix::after {
content: "";
display: table;
clear: both;
}
I want to place a button beneath my images that saying "click me" but every time I set the text, it goes to the right side of my photo and whatever I do the image doesn't move beneath the image...
I want to place the photo "cloud" on the list items, but I don't know how to do it..... do I need to position the photo with position: absolute? please help... I tried to check it online, but I didn't understand the explanation, or their issue wasn't mine, this is a small project that I am doing, just to see if I can find important stuff that I don't know how to do (:
have a good day ^-^
2 Answers
Steven Parker
243,228 PointsFor your buttons, you'll probably need to place both the images and buttons into a container (perhaps a "div"), and the style the containers to create the grid instead of the images themselves.
I'm not sure what you mean by "place the photo "cloud" on the list items". Do you mean have a tiny image in front of each item? Or use it as a background behind the item? If the latter, just set the "background-image" property.
For future use, you can share your entire project at once, including images, if you make a snapshot of your workspace and post the link to it here.
Steven Parker
243,228 PointsIt doesn't look like you implemented that last suggestion. And it doesn't involve any new HTML elements or classes.
The header HTML can remain as it was to begin with:
<div class="header">
<img src="bigcloud.png" alt="bigcloud" class="bigcloud">
<div class="list">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Me</a></li>
</ul>
</div>
</div>
And those new items from my last suggestion can just be added into the existing CSS rule:
.list li {
display: inline-block;
font-size: 1.8em;
margin: 0 4em;
margin-bottom: 0.5em
background-image: url(cloud.png);
padding: 0 30px 0 10px;
background-size: 100% 100%;
}
Idan shami
13,251 Pointsit is working, but I want the cloud a little bigger and when I change the background size, it doesn't show me the whole png.
Steven Parker
243,228 PointsThe background size is constrained to 100% in both dimensions, so it should always show the entire image. To make the cloud bigger, just increase the padding.
Idan shami
13,251 PointsTHANKS WOW U R THE BEST ^-^
Idan shami
13,251 PointsIdan shami
13,251 PointsI uploaded my project: https://w.trhou.se/uq4oxjj62y here is a photo of the page(not all of the page, I added arrows to where the buttons should be): https://imgur.com/a/IiTEb I don't know if I got your answer right... I wrapped my image and text in a div and then what... whatever I do the other photos always move to the left or the right side of the screen and never adherent to the look that they were before. and when I said, "place the photo "cloud" on the list items" I meant as a background behind the items.
thank you.
Idan.
Steven Parker
243,228 PointsSteven Parker
243,228 PointsHere's an example of wrapping the image and the button in a containing div:
Then, the container is styled with the margins instead of the image, plus it centers the button.
Idan shami
13,251 PointsIdan shami
13,251 PointsThank you !!! the buttons are good now (: only One problem P: I set the image cloud to every one of them but they don't seem to fit in the center of every cloud.
Thanks a lot!!!
Idan.
Steven Parker
243,228 PointsSteven Parker
243,228 PointsYou need a little extra room to fit the entire word within the cloud. You can add some padding for this, and then stretch the image to fit in both dimensions:
Idan shami
13,251 PointsIdan shami
13,251 Pointsstill, nothing changes...
this is my code...