Give help. Get help.

  • # March 12, 2013 at 10:07 pm

    Hi All,

    I have been trying to figure out the structure for some css created circles within a grid system. I want them to be 100% width so they scale. Just not sure on the div structure+with css
    You see it often on designers sites, circles with icons in them. Like here: Those are images but you get my meaning.

    Here is a codepen with my horrible attempt:

    Any help would be great. Always appreciate the help I get here!

    # March 13, 2013 at 1:27 am

    Use this code for the .circle class:

    .circle {
    position: relative;
    border-radius: 50%;
    width: 100%;
    height: auto;
    padding-top: 100%;
    background: white;
    make sure your padding top is the same as your width and make your height auto.

    # March 13, 2013 at 4:11 am

    > Here is a codepen with my horrible attempt:

    Your attempt isn’t bad at all, au contraire. You pretty much got everything; the problem is your container has different width and height, resulting in a rectangle, making your circle… an oval.

    # March 13, 2013 at 10:18 am

    @hugogiraudel that won’t work. He wants the circle to grow and shrink with the window size and for the circle to remain a circle.

    I believe this is what he is looking for:

    # March 13, 2013 at 10:51 am

    You can’t do that without javascript.

    Viewports aren’t square and percentages (such as have been used) are related to height and width of the viewport and nothing else.

    # March 13, 2013 at 2:55 pm

    Brilliant technique @nordstromdesign (are the position and height really necessary? seems to work without it)…how did you come up with using padding-top like that?

    # March 13, 2013 at 4:24 pm

    @CrocoDillion Yes, it does work without the height and position. I had those in the code so that when he added his icon to the circle he would be able to center it by absolutely positioning the icon.

    As for the idea; I cannot take credit for it. I discovered it here:

    # March 13, 2013 at 4:51 pm

    Still awesome, thanks :)

    # March 13, 2013 at 5:52 pm

    Just a FYI, the new viewport based vw, vh and vmin units can easily give the same results. Of course you’d end up supporting only newer browsers as there is serious lack in mobile browser support:

    Hopefully quite usable by next year. Right now I came up with this example to show how one could use viewport units and give percentages for browsers that don’t support it:

    Also shows how you can get centered stuff without any position properties. I tried to comment the CSS to give an idea of all the minor details.

    # March 14, 2013 at 1:08 am

    Amazing help as always! Thanks guys
    Thanks @nordstromdesign

    # March 15, 2013 at 3:48 pm

    >Brilliant technique @nordstromdesign (are the position and height really necessary? seems to work without it)…how did you come up with using padding-top like that?

    If no mistake, the idea first came up in A List Apart by Thierry Koblentz to keep intrinsic ratio for responsive videos:

    # April 19, 2013 at 11:08 am

    Hi all, I’ve been searching for a solution just like @norstromdesign posted. Thanks! Now I’m trying to center text on top of the circle and can’t get it lined up just right. Any help? Thanks in advance!

    # April 19, 2013 at 11:42 am


    Perhaps you could start a new thread and show us what you have so far?

    # April 19, 2013 at 3:05 pm

    I took @nordstromdesign ‘s Pen and added the psuedo element trick to vertical align the content (from [Merri’s Pen]( )


Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.