Fit image to div size [closed]

1

Well, I'm creating a mini social network but I'm having a little problem, the profile image does not fit the div.

Mycodeis:

<divclass="profilepic"></div>

<style>
.profilepic {
width: 150px;
height: 150px;
border-radius: 50%;
background-image: url(url da foto de perfil);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
</style>
    
asked by anonymous 17.07.2017 / 21:22

3 answers

2

I do not quite understand what you want, but would that be?

.profile{
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
}

.profile img{
    width: 100%;
}
<div class="profile">
        <img src="https://s-media-cache-ak0.pinimg.com/736x/92/80/c1/9280c111e34752405eb524d4ed0750e6--ian-somerholder-beautiful-men.jpg">
    </div>
    
17.07.2017 / 21:34
2

Set the size of the image, similar to that of the div

.profilepic {
width: 150px;
height: 150px;
border-radius: 50%;
background-image: url(http://1.bp.blogspot.com/-qnQOjPW5TGY/TmjhXuZGBzI/AAAAAAAAHzM/wVzoFozSlg8/s640/paisagem+peaceful_place_by_julie_rc.jpg);
background-size: 150px 150px;
background-repeat: no-repeat;
background-position: center;

}
<div class="profilepic"></div>
    
17.07.2017 / 21:29
-1

You can use background-size: cover since you are entering the image url directly in css.

.profilepic {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: url(https://i.stack.imgur.com/Rpt58.jpg) no-repeat center center;
  background-size: cover
}
<div class="profilepic"></div>
    
24.07.2017 / 19:13