For example I have such images:
and css:
.company-header-avatar{ width: 60px; height: 60px; -webkit-border-radius: 60px; -webkit-background-clip: padding-box; -moz-border-radius: 60px; -moz-background-clip: padding; border-radius: 60px; background-clip: padding-box; margin: 7px 0 0 5px; float: left; }
As the result I get:
But they are stretched. Are there any ways to make them rounded, but without stretching? (for example, get part from middle, etc)
Fiddle:
http://jsfiddle.net/73h7try9/
Those images on the site you linked to are actual size, so the simple answer is just to resize the image. You can't really do this without "stretching" the image if the image happens to be less than 300px wide or tall, but you can do it without changing the ratio, which is what I think you mean.
The CSS property border-radius adds rounded corners on images. You can round all of the image's corners or just select corners, vary the radius on different corners or display an image in the shape of an oval or a circle.
I recommend applying the images with background-image
to a div and then applying background-size: cover
to ensure the ratio stays correct regardless of the image's original size/ratio:
JS Fiddle
HTML
<div class="company-header-avatar" style="background-image: url(https://dl.dropboxusercontent.com/u/59666091/6E06C3D.jpeg)"></div> <div class="company-header-avatar" style="background-image: url(https://dl.dropboxusercontent.com/u/59666091/8WluhcUlWl8.jpg)"></div>
CSS
.company-header-avatar{ width: 60px; height: 60px; -webkit-border-radius: 60px; -webkit-background-clip: padding-box; -moz-border-radius: 60px; -moz-background-clip: padding; border-radius: 60px; background-clip: padding-box; margin: 7px 0 0 5px; float: left; background-size: cover; background-position: center center; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With