gpt4 book ai didi

html - img 是否继承父元素尺寸?

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

在下面的代码中,

<table>
<tr>
<td>
<input type="radio" name="cardtype" value="visa">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/Visa.svg/175px-Visa.svg.png"> VISA
</td>
<td>
<input type="radio" name="cardtype" value="amex">
<img src="http://www.hoax-slayer.com/images/american-express-security-update-scam-2.jpg"> AMEX
</td>
<td>
<input type="radio" name="cardtype" value="mastercard">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/MasterCard_Logo.svg/2000px-MasterCard_Logo.svg.png"> Master card
</td>
</tr>
</table>
td 中的

input 元素继承了与 img 不同的宽度。为什么?

img 元素是否继承父元素(td) 的高度和宽度? Here是完整的代码。

最佳答案

By default the <img> element does not inherit height and width of parent tag. You need to externally specify this in your custom css like:

img {
height: inherit;
width: inherit;
}

这个帖子应该可以帮助您更好地理解它:Why doesn't my image width inherit from parent div width

在您的情况下,您必须确保将正确的 css 应用到您的父节点。

关于html - img 是否继承父元素尺寸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33886892/

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