ハンバーガーメニューの実装で幅が630px以下の場合はulの要素をmax-height:0;で指定して消して、メニューボタンクリックしたら出てくるのをjqueryで実装しようとしていますがulが消えません。なぜでしょうか??
<!DOCTYPE html> <head> <meata lang="ja"> <link rel="stylesheet" type="text/css" href="design.css"> </head> <body> <header> <div class="title">Title</div> <div class="handle">Menu</div> <ul> <li><a href="#">Home</a></li> <li><a href="#">What is it?</a></li> <li><a href="#">Contact</a></li> <li><a href="#">twitter</a></li> </ul> </header> </body>
body{ padding:0; margin:0; } header{ position:relative; top:0px; left:0px; width:100%; height:4em; background-color: #F5A9A9; } .title{ font-size: 25px; color:white; font-family: arial black; position:absolute; top: 0; left: 5%; bottom: 0; margin: auto; width: 40%; height:65%; } header ul{ position:absolute; top:0; bottom:0; right:5%; vertical-align: middle; display:table; margin:auto; -webkit-transition: max-height 0.4s; -ms-transition: max-height 0.4s; -moz-transition: max-height 0.4s; -o-transition: max-height 0.4s; transition: max-height 0.4s; } header li{ border-right:solid white 0.5px; color:black; display:table-cell; padding-right:10px; padding-left: 10px; font-size: 15px; cursor:pointer; } a{ text-decoration: none; color:inherit; } .handle{ width:100%; background:inherit; text-align: center; box-sizing:border-box; padding:10px; display:none; } @media screen and (max-width:630px){ header ul{ max-height: 0;/*検証でチェックするとheight0になっているが表示されている*/ position:static; display:block; width:100%; padding:0; } .showing{ max-height: 20em; } header ul li{ /*max-height:0; liにこのように指定しても表示されてしまう*/ box-sizing:border-box; width:100%; padding:15px; display:block; text-align: center; border-bottom:solid 1px #777; } .handle{ display:block; } }

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/30 08:36
2017/04/30 08:41