如何在 Android 上为不同的移动浏览器(如 Opera Mobile 和 Firefox)进行媒体查询?当我使用某些浏览器时,CSS 确实会崩溃。
最佳答案
你不能直接使用 CSS,但你可以使用
// target mobile devices
@media only screen and (max-device-width: 480px) {
body { max-width: 100%; }
}
// recent Webkit-specific media query to target the iPhone 4's high-resolution Retina display
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
// CSS goes here
}
// should technically achieve a similar result to the above query,
// targeting based on screen resolution (the iPhone 4 has 326 ppi/dpi)
@media only screen and (min-resolution: 300dpi) {
// CSS goes here
}
也可以在HTML中定义
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="css/mobile.css" type="text/css" />
<link rel="stylesheet" media="only screen and (-webkit-min-device-pixel-ratio: 2)" href="css/mobile.css" type="text/css" />
<link rel="stylesheet" media="only screen and (min-resolution: 300dpi)" href="css/mobile.css" type="text/css" />
关于android - 移动浏览器的特定于浏览器的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6886970/