【问题标题】:Remove default size attribute of featured svg img in Wordpress [duplicate]删除 Wordpress 中特色 svg img 的默认大小属性 [重复]
【发布时间】:2015-08-21 14:09:03
【问题描述】:

我尝试为一篇帖子的特色图片上传 svg 文件,但未能显示。以下是我在开发工具中看到的。

<img width="1" height="1" src=".../featured.svg" class="attachment-large wp-post-image" alt="featured" oldsrc=".../featured.svg">

它似乎为特色图片生成了width="1" height="1"。有没有办法改变默认设置?我更喜欢更改代码而不是使用 JavaScript 来删除属性。

【问题讨论】:

  • 每个帖子图像或特定图像都会发生这种情况吗?或者特定图像自动获得宽度和高度?
  • 请参考这个SOque,它会为你解决问题。
  • @Vinayak 每个帖子中的每个 svg,帖子中的特色和图片都是。

标签: html css wordpress image svg


【解决方案1】:

您可以为每个帖子缩略图图像提供 100% 的高度和宽度:

例如:

.post img {
    height:100% !important; /* add !important */
    width:100% !important; /* add !important */
}

【讨论】:

  • 这是style 属性,不适用于width 和height 属性。
  • 它将宽度高度应用于图像。试试看。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-08-07
  • 2015-04-12
  • 1970-01-01
  • 2014-04-15
  • 1970-01-01
  • 2017-10-05
  • 2019-06-30
相关资源
最近更新 更多