Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounded corners on rectangular image using CSS only

Tags:

html

css

I'd like to create a round image from a rectangular image using radius-border.

Is there simple way to achieve this with CSS without distorting the image AND ensuring a circle is perfectly round.

See failed attempts here:

http://jsfiddle.net/v8g3y0na/

.rounded-corners-2{     border-radius: 100px;     height: 150px;     width: 150px; 

Can this be done in only CSS.....?

like image 894
Simon Avatar asked Aug 12 '14 15:08

Simon


People also ask

How do I round the corners of an image in CSS?

The border-radius CSS property is what adds the rounded corners. You can experiment with different values to get it the way you like. border-radius: 75px; If you want it to be a circle, add border-radius: 50%; .

How do you make a rectangular image round in CSS?

The main CSS property responsible for the circular shape is the border-radius property. Setting the radius of the corners to 50% of the width/height results in a circle.

How do we make a rounded corner by using CSS?

The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.


1 Answers

You do that by adding a parent div to your img and the code flows as follows

figure{     width:150px;     height:150px;     border-radius:50%;     overflow:hidden; } 

Updated Demo

like image 147
Benjamin Avatar answered Oct 09 '22 21:10

Benjamin