我正在尝试创建一个包含/排除基于最大宽度和设备像素比率的规则。例如,如果我希望排除 Kindle Fire @ 600px,但要触发 iPhone5 @640(较小的现实世界屏幕)。
以下是 AND 还是 OR 规则?假设它是一个 OR 规则,我将如何创建一个执行 AND 类型函数的规则(必须同时通过 'device-pixel-ratio of 2' 和 'max-width 749px' 检查才能触发)
@media only screen and (min--moz-device-pixel-ratio: 2),
only screen and (-o-min-device-pixel-ratio: 2/1),
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-device-pixel-ratio: 2),
only screen and (max-width: 749px){
}
编辑如下:
好的,这就是我到目前为止所拥有的 - 我猜逗号是 OR 而“and”显然是 AND。它是否正确?我正在尝试制作一组更通用的查询,而不仅仅是针对 iPhone/iPad...
@media
only screen and (max-device-width : 721px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (max-device-width : 721px) and (orientation : portrait) and (min-device-pixel-ratio: 1.5),
only screen and (max-width: 359px) {
/* All Portrait Phones */
}
@media
only screen and (min-device-width : 360px) and (max-device-width : 999px) and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-width : 360px) and (max-device-width : 999px) and (min-device-pixel-ratio: 1.5),
only screen and (max-width: 999px) {
/* Small tablets (assume vertical) and landscape phones */
}
/*note - Anything over 999 wide to render fully - desktop, landscape or large tablets */