【问题标题】:I can't get images to the same size [HTML/CSS]我无法获得相同大小的图像 [HTML/CSS]
【发布时间】:2021-02-05 12:11:22
【问题描述】:

我有两张高度为 512 像素,宽度为 512 像素的图片。无论加号大于关机按钮。

HTML:

<div class="logout">
    <a href="someLink"> 
      <img name="logout" alt="logout" src="red_shutdown.png">
    </a>
  </div>

  <div class="plus-symbol">
    <img name="plus" alt="create-post" src="plus-symbol.png">
  </div>

CSS:

div.logout {
  position: fixed;
  bottom: 10%;
  right: 1.32%;
  border: 0;
}
div.plus-symbol {

  position: fixed;
  bottom: 10%;
  right: 1.32%;
  border: 0;
}

【问题讨论】:

    标签: html css image-scaling


    【解决方案1】:

    你可以只做512*512的父标签。然后只是使图像成为 width:100%; height:100%;

    还检查检查图像是否溢出,如果是,则overflow:hidden

    【讨论】:

    • 或者只设置img height and widt 100% and max-height and max-width 512px
    【解决方案2】:

    如果这个变体不起作用,请告诉我。

    <style>
       img {
          width: 512px !important;
          height: 512px !important;
       }
    </style>
    

    你也可以把一个类放到

    就这样:

    <div class="logout">
       <a href="someLink"> 
          <img name="logout" class="img_icon" alt="logout" src="red_shutdown.png">
       </a>
    </div>
    
    <div class="plus-symbol">
       <img name="plus" class="img_icon" alt="create-post" src="plus-symbol.png">
    </div>
    
    <style>
       .img_icon {
          width: 512px !important;
          height: 512px !important;
       }
    </style>
    

    【讨论】:

    • 这里不需要使用!important。另外,无论如何你都应该避免使用!importan
    • 好的。好的,我在应用样式时不使用!important
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-27
    • 2013-09-03
    • 2013-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多