Guest User

Untitled

a guest
Jan 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. <div id="leftSide">
  2. <div id="leftSideBottom"></div>
  3.  
  4. <div id="leftSideTop">
  5.  
  6. <div id="nav">
  7. <a href="#home" class="home"></a>
  8. <a href="#about" class="about"></a>
  9. <a href="#work" class="work"></a>
  10. <a href="#blog" class="blog"></a>
  11. <a href="#connect" class="connect"></a>
  12. </div>
  13.  
  14. </div> <!-- end leftSideTop -->
  15.  
  16. </div> <!-- end leftSide -->
  17.  
  18. <div id="rightSide">
  19.  
  20. <div id="rightSideBottom"></div>
  21.  
  22. <div id="rightSideTop">
  23.  
  24. </div> <!-- end rightSideTop -->
  25.  
  26. </div> <!-- end rightSide -->
  27.  
  28. #leftSide {
  29. position: absolute;
  30. margin-top: 160px;
  31. top: 0;
  32. left: -20px;
  33. }
  34.  
  35. #rightSide {
  36. position: absolute;
  37. margin-top: 160px;
  38. top: 0;
  39. left: 880px; // ie breaks if I use right: -20px
  40. }
  41.  
  42. #rightSideTop, #leftSideTop {
  43. position: absolute;
  44. width: 100px;
  45. height: 600px;
  46. }
  47.  
  48. #rightSideBottom, #leftSideBottom {
  49. position: absolute;
  50. width: 40px;
  51. height: 600px;
  52. right: 0; // leftSideBottom will have this set to left: 0, just combine code to simplify
  53. top: 0;
  54. z-index: -100;
  55. }
  56.  
  57. .fixed {
  58. position: fixed;
  59. top: 150px;
  60. }
  61.  
  62. var aboutTop = $("#about").offset().top;
  63. var connectTop = $("#connect").offset().top;
  64.  
  65. $(window).scroll(function(){
  66. var y = $(this).scrollTop();
  67. if(y >= aboutTop && y < connectTop){
  68. $("#greenSideLeftTop,#greenSideLeftBottom").addClass("fixed");
  69. $("#greenSideRightTop,#greenSideRightBottom").addClass("fixed");
  70. }
  71. else if(y >= connectTop){
  72. $("#greenSideLeftTop,#greenSideLeftBottom").removeClass("fixed");
  73. $("#greenSideRightTop,#greenSideRightBottom").removeClass("fixed");
  74. $("#leftSide").css("top",connectTop - 1080);
  75. $("#rightSide").css("top",connectTop - 1080);
  76. }
  77.  
  78. else{
  79. $("#greenSideLeftTop,#greenSideLeftBottom").removeClass("fixed");
  80. $("#greenSideRightTop,#greenSideRightBottom").removeClass("fixed");
  81. $("#leftSide").css("top",aboutTop - 1080);
  82. $("#rightSide").css("top",aboutTop - 1080);
  83. }
  84. });
  85.  
  86. <div id="rightSide">
  87. <div id="greenSideRightTop"></div>
  88. <div id="greenSideRightBottom"></div>
  89. </div> <!-- end rightSide -->
Add Comment
Please, Sign In to add comment