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

Rheanna KIncaid
seal-mask
.a{fill-rule:evenodd;}techdegree
Rheanna KIncaid
Front End Web Development Techdegree Student 4,165 Points

Circle Diagram (Circles within Circles in CSS)

I am trying to make a circle of friends diagram using CSS with 6 circles, each inside the other and a bit smaller and a different color. Similar to this layout: http://goo.gl/syIHFp

What I've got looks pretty good, but I can't seem to get the smaller circles to center inside the larger ones.

Here is my CodePen: http://codepen.io/PixelPauline/pen/IinaF

5 Answers

In order to use vertical-align you will have to display your element as a table. Inside of the rule for .circle add

display:table;
Taylor Plante
Taylor Plante
22,283 Points

Was looking through your codepen and have a couple suggestions:

  1. I wouldn't recommend using percentage values for sizing and positioning, at least not until you've figured everything out in px (you can later convert the values if it makes sense to do so).

  2. The positioning and sizing should be done for each circle's id if you want to place one circle within the center of the next--here is an example (I didn't play around long enough to get the correct positions and sizes):

friends {

height: 100px; width: 100px; top: 100px; left: 100px; }

  1. Have you thought about creating this diagram in Illustrator or even Photoshop? It would be very easy to insert the diagram as a single image and would probably be less prone to bugs on varying devices/screen sizes.
Rheanna KIncaid
seal-mask
.a{fill-rule:evenodd;}techdegree
Rheanna KIncaid
Front End Web Development Techdegree Student 4,165 Points

Stephen- Adding the display property worked perfectly! Thanks!

Taylor- I appreciate your suggestions. I will play with using pixel units instead of percentages and positioning in the ids instead of the class. I can create just about anything in Photoshop no problemo (which is what I would probably do with this if I were actually making it as part of a website), although I don't have Illustrator. In this instance though, it was about practicing with code rather than necessarily yielding production-level output. I'm doing a couple of small projects to feel out whether or not I'm ready to move on to the next segment of the Front-End Web Development Track because it was pretty face-paced and I didn't really feel comfortable diving into JavaScript yet.

If you have any recommendations for getting really comfortable integrating HTML and CSS (like small projects) I'm all ears! : )

Alex Lewis
Alex Lewis
15,619 Points

Stephen's answer is the most succinct but I also got it to work by giving .circle a position of top: 10% and then resetting #acquitences to top: 0;

take a look: http://codepen.io/mpaarating/pen/tdGri