3

I am trying to make my images to circle.despite this image has different width and height, I want it to be circle that seems like they have same width and height length. For example; dimension of my image : 250X300. but I want it to be 200X200 circle.actually I can do this easily.the problem is doing this acording to screen size.when I turn my mobile phone to horizontal, it must change acording to screen dimensions.

my css code is below

.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;
} 
seyid yagmur
  • 1,182
  • 12
  • 23

3 Answers3

5

use vw units. They are dependent on viewport-width. so, it can be like width: 2vw;height:2vw; Circle width will depend upon the device width.

.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>
Deepak Yadav
  • 5,998
  • 5
  • 25
  • 46
1

For >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;
}

ionic2 side menu with centered image and text

Kindly lemme know if this was useful to you.

0

brother use background-size: 100% 100%; your style will be like

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

demo link: http://jsfiddle.net/vNh8t/314/

sms247
  • 4,081
  • 4
  • 29
  • 44
  • bro,it's okay but when I shrink or enlarge my screen, it must extend with same ratio.. – seyid yagmur Aug 23 '16 at 06:45
  • friend when you add background-size: 100% 100%; in your div class then size increase wrt to screen resolution ratio you can test with ctrl + "+" button you can also check my jsfiddle example – sms247 Aug 23 '16 at 06:52
  • I tried vw instead px.," Deepak Yadav ".I think I found the solution. thank you bro :) link : http://jsfiddle.net/r43LL1ny/ – seyid yagmur Aug 23 '16 at 06:55
  • great thats cool brother good luck for your remaining project :) – sms247 Aug 23 '16 at 06:59