, . , , , , . , , . - , ?:)
HTML
- - .
- button , button ? , , div, id - id class, . .mobile-nav, .
<button class="menu-btn">
<span></span>
<span></span>
<span></span>
</button>
<div class="responsive-menu">
<ul id="menu">
<li>Vote</li>
<li>Search</li>
<li>About</li>
<li>Log In</li>
</ul>
</div>
CSS
menu-btn width, #pageTitle height ( 50px - ), ; , , - id. .responsive-menu. , . css - - , ul .responsive-menu.
.menu-btn {
position:absolute;
display:block;
right:0;
top:0;
width:50px;
height:50px;
background:yellow;
border:none;
padding:16px;
}
.responsive-menu {
position: absolute;
top: 50px;
right: 0;
display: none;
}
Javascript
, class body; , - , .
$('.menu-btn').on('click', function() {
$('body').toggleClass('responsive-menu-open');
});
jsfiddle: https://jsfiddle.net/scooterlord/4atafhge/
, - , , .responsive-menu ul .. , .
: , , .
height , - "#pageTitle" relative top:100% ( ):
#pageTitle {
display: flex;
height: 50px;
position:relative;
}
.responsive-menu {
position: absolute;
top: 100%;
right: 0;
display: none;
}
: https://jsfiddle.net/scooterlord/4atafhge/1/
: , , . .menu-wrapper, float:right - . ! YAY!
.menu-wrapper {
position:absolute;
top:0;
right:0;
}
.menu-btn {
float:right;
...
}
.responsive-menu {
float:right;
clear:both; // to clear the .menu-btn and sit exactly below it
...
}
: https://jsfiddle.net/scooterlord/4atafhge/2/