当我在 CSS 中缩小图形的大小时,其中的图像保持原始大小
HTML:
<!DOCTYPE html>
<html>
<link href="style.css" rel="stylesheet">
<head>
</head>
<body>
<div id="wrapper" style="text-align: center">
<p>
Piece of text inside a 500px width div centered on the page
</p>
<figure>
<img src="https://www.newton.ac.uk/files/covers/968361.jpg">
</figure>
</div><!--wrapper-->
</body>
</html>
CSS:
#wrapper {
width: 900px;
margin: 0 auto;
}
figure {
float: left;
display: inline-block;
width: 12px;
height: auto;
}
p {
clear: both;
}
当我修改css中的width属性时,它不会影响网站上显示的图像的大小。
最佳答案
将宽度
和高度
分配给您的img
。现在,每当您更改 figure
height
和 width
时,都会根据它进行更改。
figure > img{
width:100%;
min-height:100%;
}
关于html - 在 CSS 中更改图形的大小不会影响其中的图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38711342/