Changing image sizes proportionally using CSS?

后端 未结 9 2136
面向向阳花
面向向阳花 2020-12-12 10:19

I have been trying for a couple of days now to configure my thumbnail gallery so all the images appear the same height and width. However when I change the Css code to,

相关标签:
9条回答
  • 2020-12-12 10:35

    This help me to make the image 150% with ease.

    .img-popup img {
      transform: scale(1.5);
    }
    
    0 讨论(0)
  • 2020-12-12 10:39

    if you know the spect ratio you can use padding-bottom with percentage to set the hight depending on with of the diff.

    <div>
       <div style="padding-bottom: 33%;">
          i have 33% height of my parents width
       </div>
    </div>
    
    0 讨论(0)
  • 2020-12-12 10:44
    transform: scale(0.5);
    

    Example:

    <div>Normal</div>
    <div class="scaled">Scaled</div>
    
    div {
      width: 80px;
      height: 80px;
      background-color: skyblue;
    }
    
    .scaled {
      transform: scale(0.7); /* Equal to scaleX(0.7) scaleY(0.7) */
      background-color: pink;
    }
    

    see: https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale

    0 讨论(0)
提交回复
热议问题