Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 容器上的图像大小_Html_Css - Fatal编程技术网

Html 容器上的图像大小

Html 容器上的图像大小,html,css,Html,Css,我想有一个图像,调整到容器大小 示例:容器为100x100像素,图像为90x80像素,图像的较小属性(本例中为高度)调整为容器大小,较大属性溢出容器大小 我该怎么做 我的代码: HTML 使用背景图像,例如:- div.avatar { background-image: url("paper.gif"); height: 500px; /* You must set a specified height */ background-position: cent

我想有一个图像,调整到容器大小

示例:容器为100x100像素,图像为90x80像素,图像的较小属性(本例中为高度)调整为容器大小,较大属性溢出容器大小

我该怎么做

我的代码:

HTML


使用背景图像,例如:-

 div.avatar {
     background-image: url("paper.gif");

    height: 500px; /* You must set a specified height */
      background-position: center; /* Center the image */
      background-repeat: no-repeat; /* Do not repeat the image */
      background-size: cover; /* Resize the background image to cover the entire container 
    }

您的代码似乎已经在这样做了。你的意思是你不想让一面溢出来?
  .a-avatar {
    display: block;
    width: 100px;
    height: 100px;
  }

  .a-avatar img {
    min-width: 100%;
    min-width: 100%;
    width: auto;
    height: auto;
  }
 div.avatar {
     background-image: url("paper.gif");

    height: 500px; /* You must set a specified height */
      background-position: center; /* Center the image */
      background-repeat: no-repeat; /* Do not repeat the image */
      background-size: cover; /* Resize the background image to cover the entire container 
    }