我正在尝试使用“style=”width: 100%; 调整图像大小;高度:50%”。如果更改宽度,图像会调整大小。但如果更改高度,图像不会调整大小。
那么如何改变图像的高度呢?
谢谢。
<!doctype html>
<html>
<head>
</head>
<body>
<div id="slideshow_wrap">
<!-- slide show container -->
<div class="slideshow-container">
<div class="mySlides fade-slide">
<img src="https://www.w3schools.com/howto/img_nature_wide.jpg" style="width:100%; height:100%"> <!-- changing to height:50% does not affect -->
</div>
</div>
</body>
</html>
最佳答案
要使 %
生效,您需要向 parent
添加固定高度
.parent {
height: 300px;
border: 1px solid red;
margin-bottom: 50px;
}
.h-50 {
height: 50%;
}
<div class="mySlides fade-slide parent">
<img src="https://www.w3schools.com/howto/img_nature_wide.jpg" class="h-50">
</div>
关于html - 如何调整图像的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59763901/