html - Making a whole image round in shape while maintaining aspect ratio -


i trying display whole image in circle form(without cropping or hiding part of it) while maintaining aspect ratio. want use css.

i tried this:

#propic { width:150px; height:150px; background-size:cover; display:block; border-radius:100px; -webkit-border-radius:100px; -moz-border-radius:100px; } 

which show image in circle form doesnt maintain aspect ratio. again tried this:

#propic { width:150px; height:auto; background-size:cover; display:block; border-radius:100px; -webkit-border-radius:100px; -moz-border-radius:100px; } 

which maintain aspect ratio shape becomes oval. how can achieve this?

thanks in advance.

it's not entirely clear mean 'maintain aspect ratio` since div circle. if maintain aspect ratio on wide image there blank area top , bottom fit width of circle

#propic {      width:150px;      height:150px;      border-radius:50%;      background-image: url(http://lorempixel.com/g/400/200/);      background-position: center;      background-size:100% auto;      background-repeat: no-repeat;  }
<div id="propic"></div>

as alternative can crop image left , right image still 100% tall

background-size:auto 100%; 

jsfiddle 2nd option


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -