2016-02-17 61 views
-1

我有以下代碼:如何刪除我的形象的CSS

.imgleft{ 
    background-image: url("logo.png"); 
    background-size: 100%; 
    float: left; 
} 

...但我想我的網站響應,所以當我的寬度是我希望我的形象了超過650小。

我嘗試下面的代碼,但它不工作:

@media screen and (max-width: 650px) { 
    .imgleft{ 
     background-color: none; 
    } 
} 
+0

'背景色:無;'無效。如果你想讓它消失,請使用'display:none;'代替。 –

+0

'background-image:none'爲什麼要改變'background-color'對圖像有任何影響? – zzzzBov

回答

1

你只是刪除圖像的background-color,不會隱藏它:)

display:none

嘗試
@media screen and (max-width: 650px) { 
    .imgleft{ 
     display: none; 
    } 
} 
0

您將background-color的值設置爲無,而您應該將background-image的值設置爲無。

所以,你想達到什麼樣的,是這樣的:

@media screen and (max-width: 650px) { 
    .imgleft { 
     background-image: none; 
    } 
} 

(見this Fiddle用於演示)

如果你不想或者任何背景顏色或背景 - 形象,你也可以這樣做:

@media screen and (max-width: 650px) { 
    .imgleft { 
     background-color: transparent; 
     background-image: none; 
    } 
} 

(見this Fiddle用於演示)

...或這個:

@media screen and (max-width: 650px) { 
    .imgleft { 
     background: transparent; 
    } 
} 

(也this Fiddle見)