I'm currently working on a responsive drag and drop game that utilizes Bootstrap and jQuery UI.
Within the game, I have implemented a collapsible navbar at the top of the page. To optimize space for buttons at the bottom, I am looking to hide the navbar while keeping the toggle button fixed in the corner of the screen.
Check out this screenshot of the page: https://i.sstatic.net/Xt9cq.png
The challenge I faced was ensuring that the navbar remained transparent and fixed so that the polygon behind it could still receive dropped elements. Additionally, I needed to prevent scrolling as it would interfere with the drag and drop functionality.
Here is the code snippet involved:
<nav role="navigation" class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">Connaissez vous Sain<i Style="color: #B34; font-size: 28px" class="fa fa-map-signs" aria-hidden="true"></i>é ?</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li ><a href="index.php"><span class="glyphicon glyphicon-home"
aria-hidden="true"></span> Home</a></li>
<li><a href="aboutus.html"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> About</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-list-alt"></span>
Menu <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="quartiers.php">Noms des Quartiers</a></li>
<li><a href="#">Centres des Quartiers</a></li>
<li><a href="#">Points d'interets</a></li>
<li><a href="#">Land Marks</a></li>
</ul>
</li>
<li><a href="#"><i class="fa fa-envelope-o"></i> Contact</a></li>
</ul>
</div>
</nav>
Update:
After some tweaking, I came up with a simple CSS solution:
nav {
position: fixed;
top: -60px;
}
.navbar-toggle {
position: relative;
top: 60px;
z-index: 10;
}
Here's what the updated design looks like: https://i.sstatic.net/vl043.png