Last active
December 30, 2015 20:59
-
-
Save lucperkins/7884411 to your computer and use it in GitHub Desktop.
Here's a Gist for HTML/CSS/JS for a menu bar that is both draggable and resizable AND stores the height/width and position of the bar in local storage, so that the dimensions and position persist through refresh. There is a <p> element inside of the floating bar that is the only element that can be clicked on to drag the bar. This can be disable…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="floatingMenu.css"> | |
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> | |
<script type="application/javascript" src="floatingMenu.js"></script> | |
</head> | |
<body> | |
<div id="floatingMenu"> | |
<input type="submit" id="close" value="CLOSE"> | |
<p id="dragMe">Move me</p> | |
</div> | |
</body> | |
</html> |
Sweet, thanks Than! I'm new to all this front end stuff you kids are doing nowadays, so cross-browser compatibility is a nut I haven't even begun to crack.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice demo! I can see this being cool for games - like a rearrangable HUD?
In order to work in Firefox, the body and html elements need
position:relative; height:100%
- otherwise you can only drag vertically about 4px at a time, because the page isn't any taller than the floating menu.