2017-04-20 31 views
-2

我想在手機中隱藏圖片。在手機中隱藏圖片

我所做的是:

<style> 
    @media only screen and (max-width: 500px) { 
     .kredit1 { 
      width: 100%; 
      display: none; 
     } 
    }  
</style> 

,我在給這個div推杆這個類:

<div class="" style="float: right;"> 
    <img src="_assets/_img/AAbisnode.png" style="width: 100%;"> 
</div> 

但網頁轉向只是空白,當我這樣做。

+1

您沒有在html div中添加任何類..請參閱您的代碼 –

+2

沒有類'kredit1'的元素...(此外,如果您使用display:none,則寬度規則已過時) – KarelG

+0

對於大屏幕也改變了空白的權利 –

回答

0

使用@media screen and (max-width: 600px)隱藏圖像

.kredit1 { 
 
    width: 100%; 
 
    display: block; 
 
} 
 

 
@media screen and (max-width: 600px) { 
 
    .kredit1 { 
 
    display: none; 
 
    } 
 
}
<style> 
 

 
</style> 
 
and i putted this class in to this div: 
 

 
<div class="kredit1 " style="float: right;"> 
 

 
    <img src="_assets/_img/AAbisnode.png" style="width: 100%;"> 
 

 

 
</div>

1

您的類標籤是在你的DIV空。試試這個:

<style> 
    @media only screen and (max-width: 500px) { 
     .kredit1 { 
      width: 100%; 
      display: none; 
     } 
    }  
</style> 


<div class="kredit1" style="float: right;"> 
    <img src="_assets/_img/AAbisnode.png" style="width: 100%;"> 
</div> 
1

你必須使用「@media screen和(max-width:600px)」隱藏圖像。這應該工作。