首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >针对移动浏览器的特定于浏览器的CSS

问针对移动浏览器的特定于浏览器的CSS
EN

Stack Overflow用户
提问于 2011-07-31 09:22:31
回答 1查看 5.6K关注 0票数 4

如何在Android上对不同的移动浏览器(如Opera mobile和Firefox)进行媒体查询?当我使用某些浏览器时,CSS真的崩溃了。

EN

回答 1

Stack Overflow用户

发布于 2011-08-07 09:47:28

您不能直接使用CSS,但您可以使用

代码语言:javascript
复制
// 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中定义

代码语言:javascript
复制
<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" />
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6886970

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档