RWD MOBILE FIRST NAVIGATION CSS

时间:2014-01-01 04:46:42

标签: css mobile navigation responsive-design

我无法从头开始制作自定义纯css移动首次响应式导航。我有这个导航菜单,我在互联网上找到并尝试操作代码,所以我可以在内联块上有一个水平导航栏。我希望导航栏与桌面版本一样,并且在我以最小宽度设置媒体查询时显示链接:480px并隐藏导航图标。不确定如何去做。这就是我到目前为止所拥有的。任何帮助将不胜感激,谢谢。这是我试图修改的未经编辑的原始导航条形码

DEMO:http://cssdeck.com/labs/dropdown-menu

HTML:

 <body>
<div id="header">
    <div id="logo">
    </div>

<input type="checkbox" class="checkbox" name="menu" value="mobiledropmenu" id="mobiledropmenu">
                        <label for="mobiledropmenu" class="label"><img src="http://developer.jmbarcelon.com/Images/dropmenu.png"></label>

    <div class="title">
        <div class="button">Home</div>
        <div class="button">Casa</div>
        <div class="button">Zahause</div>
        <div class="button">Maison</div>
    </div>


<h1>Drop-Down Menu</h1>

</div>

CSS:

background:#E5F2FF;
}

#header {
    width:100%;
    background:#72BBFF;
    z-index:2;
}

.checkbox {
     display: none;
} 
.label{
    -webkit-transition:.3s;
    -moz-transition:.3s;
    -o-transition:.3s;
    transition:.3s;
    width: 64px;
    height:64px;
    font-size: 20px;
    display: inline-block;
    background-size:cover;
    margin:.5em;
    background:rgba(0,132,255,0.15);
    box-shadow: 1px 1px 5px rgba(0, 135, 255,0.5);
    border-radius:1px;
}

.checkbox:checked + .label {
     -webkit-transition:.3s;
     -moz-transition:.3s;
     -o-transition:.3s;
     transition:.3s;
     box-shadow:inset 0px 0px 10px rgba(0, 135, 255,0.5);
     background:rgba(0,132,255,0.3)
}

#mobiledropmenu:checked ~ .title {
    -webkit-transition:1s;
    width: 100%;
    height: 250px;
    opacity: 1;
}

.title {
    -webkit-transition:1s;
    width: 0%;
    height: 0px;
    opacity: 0;
}

.button {
    color:#fff;
    text-decoration:none;
    border-top:1px solid #fff;
    text-align:center;
    text-transform:uppercase;
    width:100%;
    padding:1.2em;
                }

.button:hover {
    cursor:pointer;
    background:rgba(0,132,255,0.15);
        }


h1 {
    width:100%;
    color:rgba(188, 230, 255, 0.2);
    text-align:center;
    text-transform:uppercase;
    text-shadow: 1px 3px 6px #E5F2FF,
    0 0 0 #47a0d3,
    1px 4px 6px #E5F2FF;
    font-weight:lighter;
    font-size:2.5em;
    position:absolute;
    margin-top:10%;
}

@media only screen and (min-width: 480px){
    h1{color: red;}
    .label {display: none;}
    .title {display: inline-block;

1 个答案:

答案 0 :(得分:0)

好的,我删除了错误的开始,这是一个基于您编辑的问题的工作示例。我在链接代码中的CSS下添加了这个:

@media only screen and (min-width: 480px){
  /* always show the nav, and make it a fixed height */
  .title {
  width: 100%;
  height: 50px;
  opacity: 1;
  }

  /* change nav items to be horizontal and only as big as they need */
  .button {
      height: 50px;
      display: inline-block;
      width: auto;
  }
  /* hide the menu toggle button */
  .label { display: none; }
}

这样做是隐藏菜单切换并将导航切换为始终可见,并且是水平的。示例如下:http://cssdeck.com/labs/hehuga5u(调整右窗格以查看其中的操作)

同样,您必须进行调整以获得您的确切需求,但这应该更接近您的需求。祝你好运!