Advertisement
MrPauloeN

Wysuwane okienko :hover + js animate

May 14th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.48 KB | None | 0 0
  1. <div id="container">
  2. <div id="social-main"></div>
  3. <div id="social-hover"></div>
  4. </div>
  5.  
  6.  
  7. $('body').on('mouseenter','#social-hover',function(){
  8.     $('#social-hover').animate({
  9.         left: '150px'
  10.     },250);
  11.     $('#social-main').animate({
  12.         left: '0px'
  13.     },250);
  14. });
  15.  
  16.  
  17.  
  18. $('body').on('mouseleave','#container',function(){
  19.     $('#social-hover').animate({
  20.         left: '0px'
  21.     },250);
  22.     $('#social-main').animate({
  23.         left: '-150px'
  24.     },250);
  25. });
  26.  
  27.  
  28. #social-main{
  29.     position: fixed;
  30.     top: 150px;
  31.     left: -150px;
  32.     width: 150px;
  33.     height: 100px;
  34.     background: #000;
  35.     z-index: 100;
  36. }
  37. #social-hover{
  38.     position: fixed;
  39.     top: 150px;
  40.     left: 0px;
  41.     width: 50px;
  42.     height: 50px;
  43.     background: red;
  44.     z-index: 100;
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. ----------------------------------------------------
  59.  
  60.  
  61. <div id="panel">Tutaj dowolna treść</div>
  62.  
  63.  
  64. #panel {
  65.     box-sizing: border-box;
  66.     width: 200px; /* szerokość panelu */
  67.     height: 300px;
  68.     position: fixed;
  69.     top: 100px;
  70.     background-color: yellow;
  71.     border: 5px solid blue;
  72.     left: -200px; /* to samo co szerokość, ale z minusem */
  73.     transition: left 0.4s ease-out;
  74. }
  75.  
  76. #panel:after {
  77.     content: url('http://lorempixel.com/output/abstract-q-c-30-30-6.jpg'); /* obrazek "uchwytu" */
  78.     position: absolute;
  79.     right: -35px; /* tym ustawiasz pozycję "uchwytu" */
  80.     top: -5px;
  81.     cursor: pointer;
  82. }
  83.  
  84. #panel:hover {
  85.     left: 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement