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

How to make good circles CSS

HI,

How can I make circles like on this website?

I see that they use data-circle ? What is that? I mean yes, but that's an interesting way to do it.

And before after, what shoudl go in before and or after?

I know how to make some basic circle, but watever i tried with this, i can't work the before and after somehow.

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,254 Points

Hi there.

There's plenty of ways you could do this.

To make a circle you could make one with a filled colour by simply using

.circle {
  width: 300px;
  height: 300px
  border-radius: 100%;
  background: red;
}

So what you have is an element of a fixed with with the border curved in at its maximum level giving it the appearance of a circle.

Now for circles like you see in the example site I might try getting one with a radial or linear gradient applied to a border.

background: linear-gradient:
border:  30px solid

But it looks like what this website has done as superimposed one div on top of another so the biggest one has a gradient applied but the other in the middle has a white background so it looks like one bordered circle.

What's up with the technique they used? [data-circle] {} how does that work? etc.. ?