Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

image doesn't auto fix by simulating Ipad screen size

I am using wordpress to develop a website called littleboyauciton.com. I added an image at the top right of my header, and added css code:

img.sslsecure {
    max-width: 40%;
    min-height: auto;
}

This is displayed normally on my computer screen. But when I use chrome to simulate the ipad screen, the picture cannot be displayed on the header.

normal

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ipad

I added the css code corresponding to the screen in css, but it still has no any effect:

@media only screen and (max-width: 768px) {
    img.sslsecure {
    background-attachment: scroll;
    }

>Solution :

It is doing exactly what it should do, it takes up 40% of the width of it’s parent div. When you inspect the element, you can see that the parent actually almost takes up 100% of the screen width.

You can fix this by adding extra css for different screen sizes. This can be done in the theme you are using.

Or you can add extra css and write a media query yourself.

See:

https://www.w3schools.com/css/css_rwd_mediaqueries.asp

Edit.

I just saw that you’ve tried adding a media query. You did it right, yet you have to change the width of the element or the parent element. background-attachment: scroll; only applies to elements with a background-image. Since this is an img, it doesn’t apply to this element.

Let’say, I don’t want the image to be wider than 100px:

@media only screen and (max-width: 768px) {
 img.sslsecure {
  max-width: 100px;
 }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading