2016-06-21 58 views
1

我正试图隐藏仅在移动视图中使用的背景图像。隐藏某些媒体查询值中的背景图像

html{ 
background: #fff url('//www.xxxxxxxxx.xxx/gray.jpg') center top no-repeat; 
background-attachment: initial; 
background-size: contain; 
background-position-y: 0; 
} 

但是,当我这样做:

@media (max-width: 425px){ 
background: transparent !important; 
} 

背景不能识别的查询规则设置HTML。我怎样才能做到这一点?我究竟做错了什么?

+0

Alberto,我已经更新了标题以更具体到您的问题。如果我错过了某些东西,请随时回滚。 –

回答

3

您还必须在媒体查询中使用CSS选择器。在这种情况下,请添加html { ... }。试试这个:

@media (max-width: 425px){ 
    html { 
     background: transparent !important; 
    } 
}