簡體   English   中英

切換不適用於移動設備

[英]toggle doesn't work on mobile devices

我正在嘗試建立一個響應式網站。 我以前從未使用過@media標簽,所以我不確定我是否做錯了。

當窗口大小小於550px時,導航應該是一個slidetoggle菜單。

它在我減少瀏覽器窗口時起作用,但在我的iPhone上卻沒有。 我希望導航更改為550px的切換,標題高度更改為切換高度(2em)。

我希望你能幫助我。

HTML:

<meta name="viewport" content"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">


<div id="header">
    <section id="menubar">
        <ul>
            <li><a class="menubutton" href="#menu"><img src="images/menu.png" /></a></li>
        </ul>
    </section>
        <nav class="nav">
            <ul>
                <li><a href="test.html">test</a></li>
                <li><a href="test.html">test</a></li>
                <li><a href="test.html">test</a></li>
                <li><a href="test.html">test</a></li>
                <li><a href="test.html">test</a></li>
            </ul>
        </nav>
</div>

和css:

ul {
margin:0px;
padding:0px; }

li {
list-style:square;
font-weight:100;
color:#000000;
line-height:1em;
padding:0em; }

a {text-decoration: none; }

div#header {
position: fixed;
height: 6.250em;
width: 100%;
background-color: #fff;
top: 0;
z-index: 999; }

#menubar {
display:block;
background:#ffffff; }

#menubar ul {
display:block;
width:2em;
padding:0.9em; }

#menubar ul li {
display:inline; }

#menubar ul li a.menubutton {
display:none; }

#menubar img {
width:90%;
height:auto;
max-width:100%; }

nav ul {
display:block;
position: absolute;
left: 15%;
bottom: 0.625em;
font-size: 0.875em; }

nav ul li {
display:inline;
margin:0em 0.625em 0em 0em; }

nav ul li a {
color:#000; }

nav ul li a:hover {
color:#cc9900; }

nav ul li a.active {
color:#cc9900; }

@media screen and (min-width:600px) {
nav.nav {
    display:block !important;
}
}

@media screen and (max-width:550px) {
#menubar ul li a.menubutton {
    display:block;
}   
nav {
    display:none;
    height:auto;
}
nav ul li {
    display:block;
    margin:0.2em 0em 0.2em 0em;
}
}

@media screen and (max-width:550px) {
div#header {
height: 2em !important;
}

@media screen and (max-width:550px) {
div#content {
top: 2em !important;
}

我的技術是,在每次媒體查詢后,我將一個元素着色為重色,所以我可以看到什么時候發生的事情。

 @media screen and (max-width: 320px) { header { background-color: red; } } 

對我來說 - 320px =紅色,480px =橙色,760px =綠色

迎接; S

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM