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

I am trying to put a image in a box with CSS

I am trying to put a image in a box I made in CSS. I am trying to make a page similar to http://www.igshoutouts.com/ where I have a box for each Instagram page. So far I have managed to make the boxes but I am having trouble with-

  1. Putting a image in each box
  2. How it links up with instagram so it shows the amount of followers, posts etc on each page. Below is the code I did to make the boxes and repeated it 9 times for each of my Instagram pages. .box { float: left; color: black; font-size: 26px; text-align: center; background-color: white; width: 280px; margin-left: 10px; margin-right: 10px; margin-top: 30px; padding: 5px; border: 2px solid black; height: 400px

Kind regards John

2 Answers

Steven Parker
Steven Parker
243,656 Points

You didn't share your HTML, but I'm guessing the items with class box are div elements.

You can either put img elements inside them for your photos, or do like your sample website and apply background-image properties directly to the div with CSS.

Now to display data from another website like followers and posts will require either a program running on the server or some JavaScript that you load into the browser. I've not used it myself, but facebook offers a Web SDK that might be useful for creating this kind of functionality.

Thanks for your help, I just managed to sort it out.