Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. <div id="menu">
  2. <ul>
  3. <li><a href="#">Главная</a></li>
  4. <li><a href="#">Joolma</a></li>
  5. <li><a href="#">WordPress</a></li>
  6. <li><a href="#">HTML5&CSS3</a></li>
  7. <li><a href="#">PHP</a></li>
  8. </ul>
  9. </div>
  10.  
  11. CSS:
  12.  
  13.  
  14. #menu {
  15. text-transform: uppercase;
  16. text-align: center;
  17. line-height: 50px;
  18. background: #69c;
  19. text-shadow:0 1px 1px black;
  20. -moz-border-radius: 5px;
  21. -webkit-border-radius:5px;
  22. border-radius:5px;
  23. }
  24.  
  25. #menu ul {
  26. padding:0;
  27. margin:0;
  28. }
  29.  
  30. #menu li{
  31. display: inline;
  32. list-style:none;
  33. margin: 5px 10px;
  34. }
  35.  
  36. #menu li a {
  37. padding:5px 10px;
  38. color:#fff;
  39. text-decoration: none;
  40. -webkit-border-radius: 5px;
  41. -moz-border-radius: 5px;
  42. border-radius: 5px;
  43. }
  44.  
  45.  
  46. #menu li a:hover{
  47. background: #36c;
  48. color: #ff0;
  49. -webkit-transition-property: color, background;
  50. -webkit-transition-duration: 0.5s, 0.5s;
  51. }
  52.  
  53. .default {
  54. width:920px;
  55. }
  56.  
  57. .fixed {
  58. position:fixed;
  59. top:-5px; left:0;
  60. width:100%;
  61. padding:10px 0;
  62. -moz-box-shadow: 5px 5px 20px #333;
  63. -webkit-box-shadow: 5px 5px 20px #333;
  64. box-shadow: 5px 5px 20px #333;
  65. }
  66.  
  67. .transbg {
  68. background-color: rgba(60, 130, 190, 0.7)!important;
  69. }
  70.  
  71.  
  72. jQuery:
  73.  
  74. $(document).ready(function(){
  75.  
  76. var $menu = $("#menu");
  77.  
  78. $(window).scroll(function(){
  79.  
  80. if ( $(this).scrollTop() > 100 && $menu.hasClass("default") ){
  81.  
  82. $menu.fadeOut('fast',function(){
  83.  
  84. $(this).removeClass("default")
  85.  
  86. .addClass("fixed transbg")
  87.  
  88. .fadeIn('fast');
  89.  
  90. });
  91.  
  92. } else if($(this).scrollTop() <= 100 && $menu.hasClass("fixed")) {
  93.  
  94. $menu.fadeOut('fast',function(){
  95.  
  96. $(this).removeClass("fixed transbg")
  97.  
  98. .addClass("default")
  99.  
  100. .fadeIn('fast');
  101.  
  102. });
  103.  
  104. }
  105.  
  106. });//scroll
  107.  
  108.  
  109. $menu.hover(
  110.  
  111. function(){
  112.  
  113. if( $(this).hasClass('fixed') ){
  114.  
  115. $(this).removeClass('transbg');
  116.  
  117. }
  118. },
  119.  
  120. function(){
  121.  
  122. if( $(this).hasClass('fixed') ){
  123.  
  124. $(this).addClass('transbg');
  125. }
  126.  
  127. });//hover
  128.  
  129. });//jQuery
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement