css - 移动CSS不申请导航

标签 css mobile responsive-design

我只是想为较小的设备修改我网站的导航栏。该站点应保留针对 iPad+ 分辨率的固定设计,然后响应较小的分辨率。虽然移动尺寸的特定代码适用于某些类(容器、主要等),但它们似乎不适用于导航 div。您可以在此处查看它当前的运作方式:http://moore.whiterabbitstudio.us/

这是永久性的 fiddle :http://jsfiddle.net/ursalarose/xAp72/ HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<body>
<div class="container">
  <div class="main-hold">
    <div class="main">
      <div id="nav">
        <ul>
            <li><a href="index.html" class="current">Home</a></li>
          <li><a href="about.html">About Us</a></li>
          <li><a href="gallery.html">Gallery</a></li>
          <li><a href="process.html">Process</a></li>
          <li><a href="testimonials.html">Testimonials</a></li>
          <li><a href="contact.html">Contact</a></li>
        </ul>
      </div>
    </div>
  </div>
</div>
</body>

CSS:

body
{
    display: table;
    margin: 0 auto;
    letter-spacing: .1em;
    text-align: center;
    font-size: 16px;
}

*
{
  margin:0;padding:0;  
}

html,body
{
    height:100%;   
}

.container {
    height: 100%;
    display: table-cell;   
    vertical-align: middle;  
}

.main-hold {
    height:600px;
    width:1000px;
    display: table-cell;
    vertical-align: middle;
    text-align: center;
    margin-top: 0px;
    margin-right: auto;
    margin-bottom: 0px;
    margin-left: auto;
}

.main {
    height:540px;
    width:900px;
    background-position: left top;
    margin-top: 0px;
    margin-right: auto;
    margin-bottom: 0px;
    margin-left: auto;
}

/* MOBILE DEVICES */
@media screen and (max-width: 950px){

.main-hold {
    width:500px;
    display: table-cell;
    vertical-align: middle;
    text-align: center;
    margin-top: 0px auto;
}
.main {
    width:100%;
    background-repeat:no-repeat;
    background-position:center top;
    margin-top: 0px auto;
}
#nav {
    margin: 20px auto 0 auto;
    float:none;
    width: 100%;
}
#nav ul {
    list-style:none;
    }
#nav li {
    width: 100%;
    }
#nav li a {
    font-size: 14px;
    text-decoration:none;
    color:#888;
    display: block;
    text-align:center;
    width: 100%;
    height: 22px;
    display: inline;
    background-color:#CCC;
    background-image: none;
    padding-right: 0px;
    padding-top: 6px;
  -o-transition:.5s;
  -ms-transition:.5s;
  -moz-transition:.5s;
  -webkit-transition:.5s;
  transition:.5s;
}
#nav li a:hover, #nav li a.current {
    background-color:#FFF;
}

}


/* NAVIGATION */
#nav {
    float: left;
    height: 250px;
    width: 168px;
    margin-top: 60px;
}
#nav ul {
    list-style:none;
    }
#nav li {
    width: 168px;
    height: 28px;
    display: block;
    margin-bottom: 8px;
    }
#nav li a {
    font-size: 14px;
    text-decoration:none;
    color:#888;
    display: block;
    text-align: right;
    width: 148px;
    height: 22px;
    display: block;
    padding-right: 20px;
    padding-top: 6px;
  -o-transition:.5s;
  -ms-transition:.5s;
  -moz-transition:.5s;
  -webkit-transition:.5s;
  transition:.5s;
}
#nav li a:hover, #nav li a.current {
    background-color:#fff;
}

感谢您的帮助!我以前从未尝试过为移动设备设计。

最佳答案

尝试将移动 CSS 放在桌面 CSS 下方,因为桌面 CSS 现在正在覆盖移动 CSS。

关于css - 移动CSS不申请导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23519171/

相关文章:

html - 使用伪元素在圆的每一侧绘制响应线

responsive-design - Zurb 基金会 : Does the basic grid work without javascript?

html - 使用宽度属性自动调整图像大小并将它们保存在计算机上

css - 在横向/纵向中保持一致的字体大小

android - 如何在 Android 手机上安装 MySQL 以与 node.js 一起使用

css - 背景图像大小不适用于移动设备

html - 标题将包含的 div 从顶部向下推?

javascript - 从一个部分滚动到另一个部分

javascript - 将预定义的颜色序列应用于动态元素列表

javascript - 移动设备中禁用的子菜单 "mouseover"