【问题标题】:I have the following usecase and looking for the right solution我有以下用例并正在寻找正确的解决方案
【发布时间】:2023-04-05 07:17:01
【问题描述】:

嗨朋友们,我需要一个解决方案来解决元素 img 上属性宽度的错误值 100%:预期为一个数字,但看到的是 %。为此

<div class="item">
    <img alt="" src="http://web4cinema.com/img/MainBannerImageDir/146494909736kabali-new-banner-web4cinema.jpg" width="100%">
</div>

【问题讨论】:

    标签: php css html seo


    【解决方案1】:

    您好,您可以在 html 中使用 style="width: 100%",但之后只会让您的 css 变得一团糟。

    尝试在您的 css 文件上执行此操作:

    img {
      max-width: 100%;
    }
    

    img {
      width: 100%;
    }
    

    这样您就不需要在所有 img html 标签中插入 style="width: 100%"

    如果你只想使用宽度,你应该只插入 px 值或数字。

    <img src="smiley.gif" alt="Smiley face" height="42" width="42">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-11
      • 2019-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-12
      相关资源
      最近更新 更多