gpt4 book ai didi

html - 如何调整图像的高度?

转载 作者:行者123 更新时间:2023-12-04 10:44:40 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Percentage Height HTML 5/CSS

(6 个回答)


去年关闭。




我正在尝试使用 "style="width: 100%; height: 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com