I want a JS library which can allow me to build an attract开发者_运维技巧ive menu which is always visible to the user on the left side of the screen, approx. to the middle.
Since you've asked for a library, here is in jQuery.
It uses CSS position: fixed if it's available, and degrades gracefully to the javascript way if needed.
[See it in action]
CSS
#menu { 
  position: absolute; 
  left: 0; 
  top: 50%; 
  /* ... */
}
Javascript
(function() {
var $menu   = $("#menu");
var $window = $(window);
var menuHalfHeight = $menu.outerHeight() / 2;
var updateMenu = function() {
  $menu.css({
    "margin-top": - menuHalfHeight + $window.scrollTop()
  });   
};
var supportFixed = (function() {
  $menu.css({ position: "fixed" });
  updateMenu();
  return $menu.offset().top > 0; // ~150
})();      
if (!supportFixed) {
  $menu.css({ position: "absolute" });
  $window.scroll(updateMenu);
}
})();
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论