简体   繁体   English

媒体查询最大宽度不起作用

[英]media query max-width not working

To create responsive website i added media query to my css file. 为了创建响应式网站,我在我的css文件中添加了媒体查询。 If i use media query with min-width its work fine. 如果我使用最小宽度的媒体查询,它的工作正常。 When i add max width to the same its not working. 当我将最大宽度添加到相同它不起作用。 I don't know why this is happening. 我不知道为什么会这样。

@media only screen and (min-device-width : 768px) {
    #top-links{
    width: 96%;
    padding: 0 2%;
 }
#top-links #simplemenu {
    margin-left: 2%;
 }
#top-login{
    margin-right: 2%;
 }
}

This works fine. 这很好。

      @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
#top-links{
    width: 96%;
    padding: 0 2%;
}
#top-links #simplemenu {
    margin-left: 2%;
}
#top-login{
    margin-right: 2%;
}
}

 @media all and (min-device-width : 768px) and (max-device-width : 1024px) {

  }

I tried the both but not working.some one help me out. 我尝试了两者,但没有用。有人帮了我。

You have to write 你必须写

min-width

Instead of min-device-width i think. 我认为不是最小设备宽度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM