Forum Moderators: not2easy
<div class="gridContainer clearfix">
<div id="fl_menu">
<div class="labelf1">MENU</div>
<div class="menuf1">
<a href="#" class="menu_item">An menu item</a>
<a href="#" class="menu_item">A long menu item</a>
<a href="#" class="menu_item">Item 3</a>
<a href="#" class="menu_item">Another one</a>
<a href="#" class="menu_item">A really, really long menu item</a>
<a href="#" class="menu_item">Menu item 6</a>
<a href="#" class="menu_item">And one more</a>
<a href="#" class="menu_item">A tiny</a>
</div>
</div>
</div>
#fl_menu{position:absolute; top:50px; left:0px; z-index:9999; width:150px; height:50px;} <!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://k-blogger.googlecode.com/files/JQuery.easing.1.3.js"></script>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
#fl_cont{
width: 50%;
height: 50px;
min-width: 200px;
min-height: 50px;
padding-right: 20px;
padding-left: 20px;
padding-top: 20px;
padding-bottom: 20px;
margin-right: auto;
margin-left: auto;
border: 1px solid #000000;
}
#fl_menu{
position:absolute;
top:0px;
right: 0;
z-index:999;
width:150px;
height:50px;
}
#fl_menu .labelf1{
padding-left:20px;
line-height:50px;
font-family:"Arial Black", Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
background:#000;
color:#fff;
letter-spacing:7px;
}
#fl_menu .menuf1{
display:none;
}
#fl_menu .menuf1 .menu_item{
display:block;
background:#000;
color:#bbb;
border-top:1px
solid #333;
padding:10px 20px;
font-family:Arial, Helvetica, sans-serif; font-size:12px;
text-decoration:none;
}
#fl_menu .menuf1 a.menu_item:hover{
background:#333;
color:#fff;
}
</style>
</head>
<body>
<div id="fl_cont">
<div id="fl_menu">
<div class="labelf1">MENU</div>
<div class="menuf1">
<a href="#" class="menu_item">An menu item</a>
<a href="#" class="menu_item">A long menu item</a>
<a href="#" class="menu_item">Item 3</a>
<a href="#" class="menu_item">Another one</a>
<a href="#" class="menu_item">A really, really long menu item</a>
<a href="#" class="menu_item">Menu item 6</a>
<a href="#" class="menu_item">And one more</a>
<a href="#" class="menu_item">A tiny</a>
</div>
</div>
<p>i do not want this menu to go outside of this containers right hand margin. </p>
<p>i also want this menu to float when yo move the page like it does now, scroll down youll see it slowly catch up.</p>
<p> </p><p> </p><p>das</p><p>da</p><p>sd</p><p>asd</p><p>sa</p><p>d</p><p>sad</p><p>s</p><p>d</p><p>sd</p><p>sd</p><p>d</p><p>s</p><p>d</p><p>sd</p><p>d</p><p>d</p><p> </p>
</div> </div>
<script>
//config floating menu
$float_speed=10000; //milliseconds
$float_easing="easeOutQuint";
$menu_fade_speed=500; //milliseconds
$closed_menu_opacity=1.0;
//cache vars
$fl_menu=$("#fl_menu");
$fl_menu_menu=$("#fl_menu .menuf1");
$fl_menu_label=$("#fl_menu .labelf1");
$(window).load(function() {
menuPosition=$('#fl_menu').position().top;
FloatMenu();
$fl_menu.hover(
function(){ //mouse over
$fl_menu_label.fadeTo($menu_fade_speed, 1);
$fl_menu_menu.fadeIn($menu_fade_speed);
},
function(){ //mouse out
$fl_menu_label.fadeTo($menu_fade_speed, $closed_menu_opacity);
$fl_menu_menu.fadeOut($menu_fade_speed);
}
);
});
$(window).scroll(function () {
FloatMenu();
});
function FloatMenu(){
var scrollAmount=$(document).scrollTop();
var newPosition=menuPosition+scrollAmount;
if($(window).height()<$fl_menu.height()+$fl_menu_menu.height()){
$fl_menu.css("top",menuPosition);
} else {
$fl_menu.stop().animate({top: newPosition}, $float_speed, $float_easing);
}
}
</script>
</body>
</html>
#fl_menu{
position:absolute;
top:0px;
right: 0;
z-index:999;
width:150px;
height:50px;
}
#fl_menu{
position:absolute;
top:0px;
left: 50%;
margin-left:200px;
z-index:999;
width:150px;
height:50px;
}