css3转换未触发切换按钮

时间:2016-07-06 15:03:47

标签: html5 css3 transition slidedown

这是我的第二个问题! 我也在搜索问题,但没有任何帮助。 我有转换问题。我想在移动视图上选中切换按钮时,将300毫秒的过渡应用到菜单中;我在班级.menu中徒劳地尝试了负值。现在,这样菜单会滑动,但我希望它向下滑动,似乎没有任何帮助。我也试过z-index但似乎没什么用。 我真的无法弄清楚要做什么。任何可以让我朝着正确方向前进的帮助将不胜感激!

<!-- === MENUTOGGLE === -->
<input type="checkbox" name="checkbox" id="menuToggle" value="value">
<label for="menuToggle" class="menu-icon">&#9776;</label>
<!--  ==== HEADER ==== -->    
<header>
<div id="logo" class="brand">
   <h1><img src="images/logo.png" alt="Hello"></h1>
</div>`enter code here`
   <nav class="menu">
        <ul>
            <li><a href="#">Work</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Blog </a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </nav>
</header>
* {
    margin: 0;
    padding: 0;
    outline: none;
    box-sizing: border-box;
}
body {
    background: #eee;
    color: #444;
    -webkit-font-smoothing: antialiased;
    font-family: Arial, sans-serif;
    font-weight: 400;
    height: auto !important;
    height: 100%;
    min-height: 100%;
    text-rendering: optimizeLegibility;
}
header {
    display: block;
    background-color: #FFF;
    height: inherit;
}
nav {
    text-align: center;
    line-height: 3.5em;
}
nav ul {
    background-color: rgba(255, 255, 255, 0.15);
    float: none;
    line-height: inherit;
    margin: 0;
}
nav ul li {
    display: block;
    list-style-type: none;
}
nav ul li:hover {
    background-color: #ededed;
}
nav ul li a {
    text-decoration: none;
    color: #313131;
}
nav ul li a:hover {
    color: #b9b5b5;
}
#menuToggle {
    display: none;
}
.menu {
    width: 100%;
    position: absolute;
    top: 66px;
    transition: all 300ms ease-in-out;
}
.menu-icon {
    float: right;
    color: #2f2f2f;
    cursor: pointer;
    padding-top: 0.46em;
    padding-right: 1em;
    padding-left: 1em;
    padding-bottom: 0.46em;
    text-decoration: none;
    font-size: 30px;
}
.menu {
    display: none;
}
#menuToggle:checked ~ header .menu {
    display: block;
    top;
    66px;
}
#logo {
    float: none;
    text-align: left;
    padding-top: 7px;
    padding-left: 2em;
    height: inherit;
}

2 个答案:

答案 0 :(得分:0)

#menuToggle:checked ~ header .menu {
    display: block;
    top;
    66px;
}

应该是

#menuToggle:checked ~ header .menu {
    display: block;
    top: 66px;
}

答案 1 :(得分:0)

@media screen and (min-width:600px) {
#logo {
float: left;
}
.menu {
width: 100%;
height: 70px;
position: absolute;
display: block;
}
.menu-icon {
display: none;
}
header {
height: 70px;
background-color: #FFF;
margin: auto;
width: 100%;
}
nav {
height: -66px;
width: 100%;
}
nav ul {
background-color: #FFF;
display: inline;
float: right;
padding: 0.55em 2em 0 0;
height: inherit;
}
nav ul li {
display: inline;
margin: 0.2em auto;
}
nav ul li:hover {
background-color: #FFF;
}
nav ul li a {
padding: 0 2em;
}

 
<!-- === MENUTOGGLE === -->
<input type="checkbox" name="checkbox" id="menuToggle" value="value">
<label for="menuToggle" class="menu-icon">&#9776;</label>
<!--  ==== HEADER ==== -->    
<header>
<div id="logo" class="brand">
   <h1><img src="images/logo.png" alt="Hello"></h1>
</div>`enter code here`
   <nav class="menu">
        <ul>
            <li><a href="#">Work</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Blog </a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </nav>
</header>