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
John Levy
1,451 PointsTrouble with adding a image
I have several boxes each with a circle in them. I am trying to add a image to fit inside the circle. I have attached the code I used to make the circle. How do I add the image in this case it will be the image gymlife22.jpg? I have tried to add it but still having no luck. I have attached the code below Thanks in advance
3 Answers
Jacob Herrington
15,835 PointsHere is an example of where I did what I think you are trying to accomplish: https://jsfiddle.net/ekzepu02/1/
You'll want to use the background or background-image CSS rule.
John Levy
1,451 PointsThanks for your advice. I am still haovng problems. The code I am trying is
<div id="circle"></div>
#circle{
background-image: gymlife22.jpg center no-repeat;
}
What am I doing wrong?
Jacob Herrington
15,835 PointsHey John! You're close, but you need to make sure you're using the URL() argument for your rule -- even if you're referencing a file that is stored locally, you have to supply the link to the image. So if it is I'm the same directory:
#circle {
background-image: URL("image.jpg");
}
Sorry for formatting, I'm on mobile.
John Levy
1,451 PointsThanks that solved my problem
Laurie Curiant
8,965 PointsLaurie Curiant
8,965 PointsHi, you can't use src on a <div> element. if you wan't to insert an image into your <div>, it should be written like that :
<div> <img src="yourImage" /> </div>
the target="_blank" is used for the links, if you want to open them in a new window.
<a href="http://google.fr" target="_blank"></a>