CSS Media Queries not Working for Android Device

Curtis

After searching through related questions, I'm still unable to get media queries to work for my site (in progress):

http://codemusings.net/

I first ensured that my site validates as valid HTML5. I'm also using the <meta> tag with name="viewport":

<meta name="viewport" content="width=device-width,initial-scale=1">

Using help from related questions here, I went to http://mediaqueriestest.com/, which reports my Samsung Galaxy S4 as having a device-width of 640px.

I'm using a separate style sheet in which to overwrite style rules in the main style sheet.

<link rel='stylesheet' type='text/css' href='style/main.css'>
<link rel='stylesheet' type='text/css' href='style/mobile.css' media='only screen and (device-width: 640px)'>

Inside mobile.css:

nav {
  float: none;
  width: 50%;
}
main {
  float: none;
  width: 90%;
}
.section {
  background: none;
}

To ensure that the problem wasn't with clients fetching the style sheets in the wrong order, I tried appending a media query to my main CSS style sheet:

@media screen only and (device-width: 640px) {
  html { color: red; }
}

However, this didn't work either. I've been specifying device-width: 640px in an attempt to just ensure my mobile CSS works right, but my overall goal is to reliably load different CSS for all smart phones and tablets.

I should also note I'm using Chrome on my Galaxy S4.

Vitorino fernandes

try with i think this should work

@media only screen and (max-device-width: 640px) {
  html { color: red; }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

CSS Media Queries不起作用

来自分类Dev

为什么我的CSS Media Queries无法正常工作?

来自分类Dev

Android设备上的Device.Media.pickFromGallery()出现问题

来自分类Dev

Xamarin.UITests Android Device Not Detected or Not Working

来自分类Dev

CSS :focus automatically opens link on android device

来自分类Dev

在Visual Studio 2012中使用CSS Media Queries格式化文档错误

来自分类Dev

CSS Media Queries无法在手机或平板电脑上使用

来自分类Dev

使用jQuery隐藏菜单,然后通过CSS3 Media Queries重新出现

来自分类Dev

some smartphones pick up the desktop media queries?

来自分类Dev

Bootstrap - 更改 @media 或 CSS?

来自分类Dev

CSS @media标签行为奇怪

来自分类Dev

CSS Media Query不会过度

来自分类Dev

响应式CSS @media查询

来自分类Dev

CSS 中的 Jquery 和 @media

来自分类Dev

Load independant media queries for indivisual screens - Browsers support

来自分类Dev

Udate Device SDK Android

来自分类Dev

Media Query Not Working display:none to display:inline

来自分类Dev

Android Media Recorder停止异常

来自分类Dev

Android:Media Recorder无法启动

来自分类Dev

如何调试Android Media Box

来自分类Dev

Android Media Player:setDataSource失败

来自分类Dev

CSS Media查询2个不同范围

来自分类Dev

rails哪里包含@media CSS标签?

来自分类Dev

@ media屏幕CSS无法正常工作

来自分类Dev

CSS3 Media Query缩小网页

来自分类Dev

CSS Media查询无法正常工作

来自分类Dev

我的CSS @media查询找不到问题

来自分类Dev

CSS @media img [数据]不起作用?

来自分类Dev

CSS Media Query也影响其他查询