问题描述
有没有办法通过@media 只为一个特定的分辨率设置 CSS?不是 from-to px,而是仅针对一个特定数字。这不起作用:
@media (min-width: 767px) and (max-width: 767px) {
#sp-logo {width: 33.33333333%;}
}
这都不起作用:
@media (width: 767px) {
#sp-logo {width: 33.33333333%;}
}
当我覆盖两个或更多像素时,它突然起作用了。但这不是我需要的。示例:
@media (min-width: 767px) and (max-width: 768px) {
#sp-logo {width: 33.33333333%;}
}
感谢您的回答。
解决方法
您的第一个代码段适用于每隔一个像素数。它只是一个最大宽度为 767px 的错误。因此,如果您恰好需要该数字,则该技巧是一个点数(几乎 768):
@media (min-width: 767px) and (max-width: 767.9px) {
#sp-logo {width: 33.33333333%;}
}