【问题标题】:How can I hide an image on the amp version of my WordPress website?如何在我的 WordPress 网站的 amp 版本上隐藏图像?
【发布时间】:2018-05-11 09:56:10
【问题描述】:

您会在我的博文中注意到:http://www.profitanywhereblog.com/twitter-following/ 我在博文顶部有一张右对齐的图片。我想隐藏该图像,但仅限于我网站的 amp 版本。

我读到here 说任何放大器自定义都应该包含在这样的样式标签中:

<style amp-custom>
img.alpha {
    display: none;
}
</style>

(我给了我想隐藏类“alpha”的图像,因为我知道我的其他网站图像都没有这个类)。

我使用这个插件把这段代码放在网站的头部:https://wordpress.org/plugins/header-and-footer-scripts-inserter/

它使我的图像在非 amp 版本中消失,但图像仍保留在我网站的 amp 版本中。

由于我是博主,而不是编码员,因此我将不胜感激。

【问题讨论】:

  • 顺便说一句,我已经从我的网站头部删除了该代码。

标签: html css wordpress amp-html


【解决方案1】:

试试这个 css 来隐藏 amp 页面中的图片

amp-img {
  display:none;
}

【讨论】:

  • 如果可能的话,你能在这里添加 amp 渲染的 html 代码吗?
  • 我不知道该怎么做。
【解决方案2】:

试试这个:

<style amp-custom>
amp-img.alpha.alignright {
    display: none;
}
</style>

您只需要一个比 amp css 中的选择器更强大的选择器。

【讨论】:

  • 谢谢,迪奥戈。不幸的是,该代码没有改变任何东西。但是我把它留在了头上,以防你可以检查元素并查看是否存在冲突。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-11
  • 1970-01-01
  • 2017-03-08
  • 1970-01-01
  • 2013-11-16
  • 1970-01-01
  • 2015-11-30
相关资源
最近更新 更多