简体   繁体   中英

How do I prevent images from displaying on my responsive website at mobile dimensions?

I currently have a right-aligned image in the main body of a WordPress post, which I have placed using the WYSIWYG editor. However, I would like to prevent this image from displaying on devices with a max-width of 320px.

I am using a responsive theme but do not wish to change the way that other images on the website behave. For this reason, is it possible to target that image specifically? If so, how would I do this?

Bonus: I originally wanted to change the alignment and margins of the image at mobile width but have been unable to figure out how to do this without changing the way that it behaves at bigger screensizes.

Have been unable to find a solution thus far.

Thanks!

you could use media queries on the editor go to the html editor an add an id to that particular image for example <img id="target" src="some/image.jpg" />

then you could paste this on your style.css file

@media only screen  and (min-device-width : 320px)  {
 #target{ display: none; }
}

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