gpt4 book ai didi

html - 如何使用 css 删除图像的宽度和高度值?

转载 作者:行者123 更新时间:2023-11-28 04:54:08 25 4
gpt4 key购买 nike

假定 div(id="leaderboardimage")的所有子图像的宽度值为 100%。所以我们有:

#leaderboardimage img{
width:100%;
height:auto;
min-width:100%;
max-width:100%;
}

但现在我想向这个 div 添加一个新图像,但我不想应用上述样式。我怎样才能重置这个特定图像的宽度和高度值(它嵌套在一个带有 `class="creatortag"的元素中)。

以下样式不起作用:

#leaderboardimage .creatortag img{
width:auto;
height:auto;
min-width:0;
max-width:100%;
}

这是 HTML 示例:

<div id="leaderboardimage">
<a class="creatortag">
<img /> an exception for the genarl css rule
</a>
<img />ordinary images
<img />ordinary images
</div>

非常感谢。

最佳答案

要重置最大值,您可以使用 none 关键字。要重置最小值,您可以使用 0。所以……

#leaderboardimage .creatortag img{
width: auto;
height: auto;
min-width: 0;
max-width: none;
}

...应该这样做。

(注意:顺便说一下,将最大值重置为 100% 不会“默认”最大宽度,因为 100% 仍然可能比实际图像宽度小/大,因为包装宽度)

关于html - 如何使用 css 删除图像的宽度和高度值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26516272/

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