简体   繁体   中英

How to hide image when resizing using max-device-width?

Need to have the img disappear when i'm viewing on a mobile device

 <div id="art">
<img src="../images/canO.jpg" alt="" width="500" height="500"/>
</div>

@media screen and (max-device-width:450px) {...}}

Use this media query.

 @media screen and (max-device-width:450px) { #art img{ display:none; } } 

I don't understand properly what you are asking. If it is not the solution what you need, please explain your question further more. :) :)

Sorry , hurried I wanted to write like this DEMO

@media screen and (max-width:450px){
    #art img{
        display:none;
    }
}

or

   @media screen and (max-width:450px){
        #art img{
             visibility: hidden;
        }
    }

You mean this?

@media screen and (max-device-width:450px){
    #art img{
        display:none;
    }
}
@media screen and (max-device-width:450px) {  .art img { display: none !important;} 

You can hide the whole div #art { display:none; } #art { display:none; } or add a class to the image. Alternatively hide the images in the div with #art img { display:none; } #art img { display:none; }

I would just use screen-width, like so:

@media screen and (max-width:450px) {   
  #art {         
     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