媒体查询未被识别

时间:2014-04-21 14:50:38

标签: css css3 media-queries

基本上我正在尝试编写一些响应式代码,但我无法让它工作。我做错了什么?

这是删除了无关位的页面代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Zinuru Project | Tighe O'Connor</title>

<!-- Site Stylesheet(s) -->
<link rel="stylesheet" type="text/css" href="scripts/zinuru.css" >
<link rel="stylesheet" type="text/css" href="scripts/zinuru-media-queries.css">

<!-- JQuery Stylesheet(s) -->
<link href="scripts/lightbox.css" rel="stylesheet" type="text/css">

</head>

<body id="<%=(rsMainMenu.Fields.Item("menuClass").Value)%>">

<div id="pageWrapper">

<aside>
<!--#include file="includes/aside.asp" -->
</aside>

<article>

<header>
<!--#include file="includes/header.asp" -->
</header>

<nav>
<!--#include file="includes/navbar.asp" -->
</nav>

<figure class="banner_slider">
<% 
While ((rpt_Images__numRows <> 0) AND (NOT rsImages.EOF)) 
%>
<img src="images/<%=(rsImages.Fields.Item("imageName").Value)%>" class="nailthumb-container">
<% 
rpt_Images__index=rpt_Images__index+1
rpt_Images__numRows=rpt_Images__numRows-1
rsImages.MoveNext()
Wend
%>
</figure>

<div id="content"><%=(rsContent.Fields.Item("content").Value)%></div>
</article>

</div>
<!-- /#pageWrapper -->

<!-- JQuery Runtime -->
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

<!-- JQuery Plugins -->
<script src="scripts/jquery.nailthumb.1.1.js" type="text/javascript"></script>
<script src="scripts/lightbox-2.6.min.js" type="text/javascript"></script>
<script src="scripts/cycle.js" type="text/javascript"></script>

<!-- Local Scripts -->
<script type="text/javascript" src="scripts/localscripts.js"></script>

</body>
</html>

这是主要的网站样式表:

/* CSS crunched with Crunch - http://crunchapp.net/ */
@import "/scripts/html5reset-1.6.1.css";
@import "/scripts/muli.css";
@import "/scripts/painted.css";
/**************************************************************************************
 GENERAL STYLING
**************************************************************************************/
body {
  background-color: #161616;
  font-family: 'MuliRegular';
  color: #616163;
  font-size: 1em;
}
#pageWrapper {
  position: relative;
  top: 35px;
  width: 836px;
  margin: auto;
}
a {
  outline: 0;
  outline: none;
}
#home .home,
#artist .artist,
#installations .installations,
#paintings .paintings,
#reviews .reviews,
#teaching .teaching {
  color: #ffffff;
}
/**************************************************************************************
 HEADER
**************************************************************************************/
header {
  height: 35px;
}
header #logo {
  text-align: right;
}
header #logo #zinuru {
  display: none;
}
header #logo #tighe {
  font-family: 'MuliLight';
  font-variant: small-caps;
  font-size: 1.6em;
  color: #ffffff;
}
/**************************************************************************************
 NAVIGATION BAR
**************************************************************************************/
nav {
  width: 706px;
  height: 40px;
  text-align: center;
}
nav dl {
  padding: 0;
  margin: 0;
  display: inline-block;
  position: relative;
  text-align: left;
}
nav dl a {
  display: block;
  white-space: nowrap;
  text-decoration: none;
  color: #616163;
}
nav dl {
  *display: inline;
}
nav dt {
  height: 35px;
  line-height: 35px;
}
nav dt a:hover {
  color: #ffffff;
}
nav dd {
  position: absolute;
  left: 0;
  margin: 0;
  display: none;
  background: #161616;
  box-shadow: 1px 1px 2px #949494;
  min-width: 190px;
  padding: 0 3px;
  z-index: 1000;
}
nav dd a {
  color: #949494;
  line-height: 25px;
}
nav dl.right dd {
  text-align: right;
  left: auto;
  right: 0;
}
nav dl:hover dd {
  display: block;
}
nav dl dd a:hover {
  color: #ffffff;
}
nav .menuDivider {
  margin: 0 5px;
  color: #FFF;
}
/**************************************************************************************
 ASIDE
**************************************************************************************/
aside {
  width: 130px;
  float: left;
}
aside #zinuru {
  position: fixed;
  margin: 240px 0 0 -195px;
  width: 500px;
  -moz-transform: rotate(270deg);
  -webkit-transform: rotate(270deg);
  -o-transform: rotate(270deg);
  -ms-transform: rotate(270deg);
  transform: rotate(270deg);
  font-family: 'painted';
  font-size: 5.5em;
  color: #ffffff;
}
/**************************************************************************************
 ARTICLE
**************************************************************************************/
article {
  margin-left: 130px;
  width: 706px;
  /**************************************************************************************
 PAINTINGS
**************************************************************************************/
}
article p {
  margin-bottom: 10px;
  line-height: 120%;
  text-align: justify;
}
article h1 {
  font-family: 'painted';
  font-size: xx-large;
  color: #ffffff;
  margin: 20px 0 10px;
}
article figure {
  border: #FFF thin solid;
}
article #content {
  margin-top: 15px;
}
article table.paintings {
  width: 706px;
}
article table.paintings tr {
  text-align: center;
}
article table.paintings td {
  padding-bottom: 6px;
}
article .paintingsThumbs {
  width: 140px;
  height: 140px;
}
/**************************************************************************************
 THUMBNAIL CONTAINER
**************************************************************************************/
.nailthumb-container {
  width: 706px;
  height: 211.8px;
}

这是我的起点媒体查询样式表:

/* CSS crunched with Crunch - http://crunchapp.net/ */
/**************************************************************************************
 SCREEN 320px
**************************************************************************************/
@media only screen and (max-device-width: 320px) {
  #pageWrapper {
    top: 0;
    width: 300px;
    margin: auto;
  }
  header {
    height: 60px;
  }
  header #logo #zinuru {
    display: block;
    line-height: 5px;
  }
  header #logo #tighe {
    font-size: 1em;
  }
  nav {
    display: none;
  }
  aside {
    display: none;
  }
}

希望你能看到我出错的地方以及我需要改变的地方。

非常感谢提前。

1 个答案:

答案 0 :(得分:2)

变化:

@media only screen and (max-device-width: 480px) { ... }

为:

@media only screen and (max-width: 480px) { ... }

您的网站将通过移动设备和桌面进行响应。

使用max-device-width这些规则仅在物理设备的屏幕宽度小于X px时启动,如果您调整浏览器大小则不会。我将号码更改为480px,因为它是iphone屏幕的标准宽度。 320px太小了。

也可以使用:

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

initial-scale设置移动设备为100%创建的虚拟比例,以便正确查看您的网站。