2017-04-17 62 views
1

我有顯示圖像的模式。我將圖像的高度設置爲90%模式,寬度自動縮放,因此圖像不會被拉伸。但在手機上,我想height不被定義,我只想定義寬度爲100%。我如何在未定義的小屏幕上創建圖像高度?直到現在我有這樣的代碼:在指定的屏幕寬度上使css類無效

.image { 
    height: 80%; 
} 
@media only screen and (max-width: 700px){ 
    .image { 
    width: 100%; 
    /* make height not defined?! 
    } 
} 

回答

1

在手機屏幕上使用height: auto;

@media only screen and (max-width: 700px){ 
    .image { 
    width: 100%; 
    height: auto; 
    } 
} 
+0

它仍然是同樣的結果,似乎不會讓第一高度定義無效.. – sking

1
@media only screen and (max-width: 700px){ 
    .image { 
    width: 100%; 
    height: auto; 
    } 
}