代码之家  ›  专栏  ›  技术社区  ›  Daniel1490

不同设备的不同样式表

  •  2
  • Daniel1490  · 技术社区  · 9 年前

    @media screen and (max-width:720px){/*code for mobile here*/}
    @media screen and (min-width:1280px) {/*code for PC here*/}
    

    但我认为这会给大分辨率移动设备和低分辨率桌面显示器带来问题。 所以我想知道有没有办法根据设备类型(如智能手机、平板电脑或PC)更改css文件/选择css代码的确切部分?

    任何有效的方法都会有所帮助。如果有什么不清楚的地方,我会尽量解释得更好。如果我错了,纠正我。

    1 回复  |  直到 9 年前
        1
  •  3
  •   Fabio Marzocca    9 年前

    您可以使用这些:

    // Large devices (desktops, less than 1200px)
     @media (max-width: 1199px) { ... }
    
     // Medium devices (tablets, less than 992px)
     @media (max-width: 991px) { ... }
    
     // Small devices (landscape phones, less than 768px)
     @media (max-width: 767px) { ... }
    
     // Extra small devices (portrait phones, less than 576px)
     @media (max-width: 575px) { ... }