媒体查询是否仍在使用

时间:2014-07-01 15:54:48

标签: media-queries

媒体查询是否仍然可以在不同设备上管理ui或现在使用其他设备?如果是这样,有人可以用一些好的资源来帮助我学习它们吗?

谢谢!

2 个答案:

答案 0 :(得分:2)

这些是标准设备的一些常见媒体查询。

/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}

/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}

/* Smartphones (portrait) ----------- */
@media only screen and (max-width : 320px) {
/* Styles */
}

/* iPads (portrait and landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/* Styles */
}

/* iPads (landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
/* Styles */
}

/* iPads (portrait) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
/* Styles */
}
/**********
iPad 3
**********/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* Desktops and laptops ----------- */
@media only screen  and (min-width : 1224px) {
/* Styles */
}

/* Large screens ----------- */
@media only screen  and (min-width : 1824px) {
/* Styles */
}

/* iPhone 4 ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}

@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}

通过查看stats来找到目标也很有帮助。

Top 14 desktop, mobile and tablet screen resolutions from 2012 to 2013

如果您想在物理上测试某个设备,可以查看here

答案 1 :(得分:1)

媒体查询经常用于确定屏幕尺寸断点的响应式设计(有些人会说是其中一个基础)。

考虑以下资源:

一个例子:

<style>
@media (min-width: 500px) {
  .my_div{
    display: none;
  }
}
@media (min-width: 501px) and (max-width: 1199px) {
  .my_div {
    display: block;
    width: 200px;
  }
}

@media (min-width: 1200px) {
  .my_div {
    display: block;
    width: 400px;
  }
}

</style>