如何强制 `img` 标签尊重父 `picture` 参数?
How to force `img` tag to respect parent `picture` parameters?
有什么方法可以使 img
元素(设置为 width:100%
)跟随父 <picture>
元素的 width
属性?这里有一个例子来演示,它只遵循 "style" 属性,而不是属性:
First:
<picture width="15" style="display:inline-block;">
<img src="https://i.imgur.com/FqUFgYd.png" style="width: 100%;">
</picture>
Second:
<picture width="15" style="display:inline-block; width:15px;">
<img src="https://i.imgur.com/FqUFgYd.png" style="width: 100%;">
</picture>
因为<picture>
元素supports only global attributes,所以<picture>
元素不支持width="15"
。它只能通过在 CSS 中定义 <picture>
元素,添加 ID/class 或添加 **style=""**
进入元素.
Second:
<picture style="display:inline-block; width:15px;">
<img src="https://i.imgur.com/FqUFgYd.png" style="width: 100%;">
</picture>
有什么方法可以使 img
元素(设置为 width:100%
)跟随父 <picture>
元素的 width
属性?这里有一个例子来演示,它只遵循 "style" 属性,而不是属性:
First:
<picture width="15" style="display:inline-block;">
<img src="https://i.imgur.com/FqUFgYd.png" style="width: 100%;">
</picture>
Second:
<picture width="15" style="display:inline-block; width:15px;">
<img src="https://i.imgur.com/FqUFgYd.png" style="width: 100%;">
</picture>
因为<picture>
元素supports only global attributes,所以<picture>
元素不支持width="15"
。它只能通过在 CSS 中定义 <picture>
元素,添加 ID/class 或添加 **style=""**
进入元素.
Second:
<picture style="display:inline-block; width:15px;">
<img src="https://i.imgur.com/FqUFgYd.png" style="width: 100%;">
</picture>