DEV Community

Cover image for Circular images with CSS
Adam K Dean
Adam K Dean

Posted on

1

Circular images with CSS

A trend which, while it has been around for a while, seems to be showing up more and more these days is circular images. These are quite easy to do using border-radius, and below you can see how. You can either use a background-image in CSS, or add the border-radius to an img tag, which I prefer.

We'll use this picture of William Shakespeare.

.circular {
    width: 300px;
    height: 300px;
    border-radius: 150px;
    -webkit-border-radius: 150px;
    -moz-border-radius: 150px;
}


<!-- regular image -->
<img src="http://i.imgur.com/jZN7xit.jpg">

<!-- circular image -->
<img src="http://i.imgur.com/jZN7xit.jpg" class="circular">
Enter fullscreen mode Exit fullscreen mode

And the output:

Circular images with CSS

One thing to bear in mind is that the border-radius must be half the height and width in order to make the image circular. Width & height equal 300px, border-radius equals 150px. Width & height equal 600px, border-radius equals 300px.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️