0

I am using bootstrap with Angular 9 and a rounded profile picture. If I put width: 19rem and height: 19rem the picture keeps rounded but when I have a smaller resolution it overflows onto the next column.

Is there any way to keep width 100% and the height dynamically changes so it has the same aspect ratio (rounded)?

Thank you so much!

.mainImage {
  height: 19rem;
  width: 19rem;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  border-radius: 100%;
  border: 5px #35c68f solid;
}
matthias_h
  • 11,356
  • 9
  • 22
  • 40
kokorosama
  • 31
  • 4

2 Answers2

1

Use view port:

fiddle to check responsiveness.

.mainImage {
  height: 15vw;
  width: 15vw;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  border-radius: 100%;
  border: 5px #35c68f solid;
}
<div>
  <img class="mainImage" src="http://placekitten.com/301/301">
</div>

on 65vm size:

.mainImage {
  height: 65vw;
  width: 65vw;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  border-radius: 100%;
  border: 5px #35c68f solid;
}
<div>
  <img class="mainImage" src="http://placekitten.com/301/301">
</div>
Manjuboyz
  • 6,978
  • 3
  • 21
  • 43
0

If what I understand is: if you want all image to fit a rounded circle, you can include this to image

img = { object-fit: cover; } 
Oghomwen Oguns
  • 161
  • 1
  • 7