Html 容器上的图像大小
我想有一个图像,调整到容器大小 示例:容器为100x100像素,图像为90x80像素,图像的较小属性(本例中为高度)调整为容器大小,较大属性溢出容器大小 我该怎么做 我的代码: HTMLHtml 容器上的图像大小,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
使用背景图像,例如:-
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
}