简体   繁体   中英

How can I hide an image on the amp version of my WordPress website?

You'll notice on my blog post here: http://www.profitanywhereblog.com/twitter-following/ I have a right aligned image at the top of the post. I'd like to hide that image but only on the amp version of my website.

I read here that any amp customizations should be enclosed in style tags like this:

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

(I gave the image I want to hide the class "alpha" since I know none of my other website images have that class).

I put this code in the head section of website using this plugin: https://wordpress.org/plugins/header-and-footer-scripts-inserter/

It made my image disappear in the non-amp version but the image remained in the amp version of my site.

I'd appreciate some help as I'm a blogger, not a coder.

Try this css to hide images form the amp page

amp-img {
  display:none;
}

try this:

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

You just needed a stronger selector than the ones in the amp css.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM