使用 css 根据屏幕尺寸制作圆形图像

make circle image acording to screen size with css

我正在尝试将我的图像制作成 circle.despite 此图像具有不同的宽度和高度,我希望它是圆形,看起来它们具有相同的宽度和高度长度。 例如;我的图像尺寸:250X300。 但我希望它是 200X200 circle.actually 我可以做到 easily.the 问题是根据屏幕做这个 size.when 我把我的手机 phone 变成水平的,它必须根据屏幕尺寸。

我的css代码如下

.image {
     height: 100px; 
     width: 100px; 
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 5px gray;
    display: inline-block;
    margin-left: auto;
    margin-right: auto;
} 

兄弟使用background-size: 100% 100%; 你的风格会像

 div { 
        background-size: 100% 100%;
        background-repeat: no-repeat;
        border-radius: 50%;
        width: 200px;
        height: 200px;
    }

演示 link: http://jsfiddle.net/vNh8t/314/

使用大众单位。它们取决于视口宽度。所以,它可以像 width: 2vw;height:2vw;圆圈宽度将取决于设备宽度。

.image {
     height: 5vw; 
     width: 5vw; 
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 5px gray;
    display: inline-block;
    margin-left: auto;
    margin-right: auto;
} 
<div class="image"></div>

对于 >ionic2

<ion-card text-center class="hide-card">
    <img src="http://placehold.it/300x200" class="custom-avatar"/>
    <h2>Victorcodex</h2>
    <p>Have some p tag here</p>
    <p>I am the third guy inline here</p>
    <hr>
</ion-card>

.hide-card {
  -webkit-box-shadow: none!important;
}

.custom-avatar {
  height: 30vw;
  width: 30vw;
  border: 1px solid #fff;
  border-radius: 50%;
  display: inline-block;
  margin-left: auto;
  margin-right: auto;
}

请告诉我这是否对您有用。