0

this is my very second question! I also searched in the questions but nothing helps. I have a problem with transitions. I am trying to apply a 300ms transition to the menu when the toggle button is checked on mobile view; I tried in vain with negative values in the class .menu. Now, doing so the menu slides up but I want it to slide down and nothing seems to help. I also tried with the z-index but nothing seems to work. I really can't figure out what to do. Any help that could send me on the right direction would be greatly appreciated!

<!-- === 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;
}
JayC
  • 7,053
  • 2
  • 25
  • 41
  • Since you can't animate the `display` property, you can use `max-height`, as showed in the dupe link. – Asons Feb 02 '18 at 13:23

2 Answers2

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

should be

#menuToggle:checked ~ header .menu {
    display: block;
    top: 66px;
}
CSS Apprentice
  • 899
  • 1
  • 16
  • 29
  • Hello there and thank you for the answer. Actually I don't think it works well simply because in this way my menu using media querries simply disappears and collapses. – Ryan Ragnini Jul 06 '16 at 19:09
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>