According to a book, the example below should fade-in and -out the menu, but Instead the menu disappears immediately. I believe the problem is that display: none take effect too early somehow, but I am not sure since it says display: block in the animation.  
What can I do to make the grey div fade out smooth instead of just disappearing? A solution only using CSS for the animation would be preferred.
CSS
a {
    color: white;
    text-align: center;
}
.bar {
    height: 20px;
    background: red;
}
.div {
    background: silver;
    padding: 10px;
}
@-webkit-keyframes fade {
  0% {
    opacity: 0;
    display: block;
  }
  100% {
    opacity: 1;
    display: block;
  }
}
@keyframes fade {
  0% {
    opacity: 0;
    display: block;
  }
  100% {
    opacity: 1;
    display: block;
  }
}
.hidden {
    display: none;
    -webkit-animation: fade 2s reverse;
    animation: fade 2s reverse;
}
.shown {
    display: block;
    -webkit-animation: fade 2s;
    animation: fade 2s;
}
HTML
<div class="bar">
    <a href="#" class="click">Click Me</a>
    <div class="div shown">
        <p>Hello</p>
    </div>
</div>
jQuery
$(function() {
    $div = $(".div");
    var menu = function () {
        if ( $div.hasClass("shown")) {
            $div.removeClass("shown");
            $div.addClass("hidden");
        } else {
            $div.removeClass("hidden");
            $div.addClass("shown");
        }
    }
    menu();
    $(".click").bind("click", menu);
});
Fiddle: http://jsfiddle.net/hFdbt/1/
 
     
     
    