gpt4 book ai didi

html - 为什么我的图像会粘在容器底部?

转载 作者:太空宇宙 更新时间:2023-11-04 03:22:00 25 4
gpt4 key购买 nike

当我尝试将“垂直规则”置于图像右侧时,图像会粘在容器底部。

Play Button

<div>
<div style="display:inline-block; width:210px;">
<img src="res/img/PlayBtn.png" style="top:-100px; padding:5px;">
</div>
<div style="display:inline-block; width:12px;">
<div style="height:450px; width:0px; border:1px solid #000; margin:5px; margin-top:0px;"></div>
</div>
</div>

我怎样才能做到这一点,同时将图像保持在顶部?

最佳答案

inline-block 元素的默认定位是baseline。设置:vertical-align:top 在你的 div 上

<div>
<div style="display:inline-block;vertical-align:top; width:210px;">
<img src="res/img/PlayBtn.png" style="top:-100px; padding:5px;">
</div>
<div style="display:inline-block;vertical-align:top; width:12px;">
<div style="height:450px; width:0px; border:1px solid #000; margin:5px; margin-top:0px;"></div>
</div>
</div>

关于html - 为什么我的图像会粘在容器底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27735838/

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