Blogger Information
Blog 14
fans 0
comment 0
visits 8050
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
拖动的页面 滚动导航固定上方
「flasky」
Original
512 people have browsed it

拖动的页面 滚动导航固定上方

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. *{
  8. margin: 0;
  9. padding: 0;
  10. }
  11. .bg-img{
  12. background: url("http://9yin2.woniu.com/static/web201703/images/bg.jpg") center top repeat;
  13. width: 100%;
  14. height: 1080px;
  15. }
  16. .top-p{
  17. width: 100%;
  18. height: 130px;
  19. background: rgba(30, 33, 35,0.8);
  20. }
  21. .w-100{
  22. width: 100%;
  23. }
  24. .op-02{
  25. opacity: 0.2;
  26. }
  27. .white{
  28. color: white;
  29. }
  30. .d-flex{
  31. display: flex;
  32. }
  33. .just-btw{
  34. justify-content: space-between;
  35. }
  36. .just-round{
  37. justify-content: space-around;
  38. }
  39. .just-center{
  40. justify-content: center;
  41. }
  42. .pd-1{
  43. padding: 5px;
  44. }
  45. .pd-2{
  46. padding: 10px;
  47. }
  48. .pd-3{
  49. padding: 15px;
  50. }
  51. .pd-4{
  52. padding: 20px;
  53. }
  54. .pd-5{
  55. padding: 25px;
  56. }
  57. .pd-6{
  58. padding: 30px;
  59. }
  60. .mr-1{
  61. margin: 5px;
  62. }
  63. .mr-2{
  64. margin: 10px;
  65. }
  66. .mr-3{
  67. margin: 15px;
  68. }
  69. .mr-4{
  70. margin: 20px;
  71. }
  72. .mr-5{
  73. margin: 25px;
  74. }
  75. .mr-6{
  76. margin: 30px;
  77. }
  78. .f-size-14{
  79. font-size: 14px;
  80. }
  81. .f-size-16{
  82. font-size: 16px;
  83. }
  84. .f-size-18{
  85. font-size: 18px;
  86. }
  87. .f-size-20{
  88. font-size: 20px;
  89. }
  90. .f-size-12{
  91. font-size: 12px;
  92. }
  93. .cursor{
  94. cursor:pointer;
  95. }
  96. .inde{
  97. z-index: -1;
  98. }
  99. .new-box{
  100. width: 100%;
  101. height: 1072px;
  102. display: block;
  103. background: url("http://9yin2.woniu.com/static/web201703/images/p2_bg.jpg") center top repeat;
  104. }
  105. .feature-box{
  106. width: 100%;
  107. height: 1113px;
  108. background: url("http://9yin2.woniu.com/static/web201703/images/p3_bg.jpg") center top repeat;
  109. }
  110. .w-1200{
  111. width: 1200px;
  112. }
  113. .m-center{
  114. margin: 10px auto;
  115. }
  116. .pos-abv{
  117. position: absolute;
  118. }
  119. </style>
  120. </head>
  121. <body>
  122. <div id="top"><img src="http://9yin.woniu.com/static/web201588/images/bg.jpg?v1" alt=""></div>
  123. <section class="pos-abv w-100" id="nav">
  124. <div class="d-flex just-btw w-100 top-p">
  125. <div><img src="http://9yin2.woniu.com/static/web201703/images/logo.png" alt=""></div>
  126. <div class="d-flex just-round f-size-18 white">
  127. <div class="mr-4 cursor">
  128. <p class="">官网首页</p><p>HOME</p>
  129. </div>
  130. <div class="mr-4 cursor">
  131. <p>新闻资讯</p><p>NEWS</p>
  132. </div>
  133. <div class="mr-4 cursor">
  134. <p>研发手札</p><p>DEV SKETCH</p>
  135. </div>
  136. <div class="mr-4 cursor">
  137. <p>官方论坛</p><p>FORUM</p>
  138. </div>
  139. <div class="mr-4 cursor">
  140. <p>蜗牛游戏</p><p>GAME</p>
  141. </div>
  142. </div>
  143. </div>
  144. <div>
  145. <div>
  146. <img src="http://9yin2.woniu.com/static/web201703/images/slogan.png" alt="">
  147. </div>
  148. </div>
  149. </section>
  150. <div id="myMain">
  151. <section class="bg-img"></section>
  152. <section class="new-box">
  153. <div class="w-1200 m-center pd-6">
  154. <img src="https://img.php.cn/upload/image/136/485/911/1638173810418146.gif" alt="">
  155. </div>
  156. </section>
  157. <section class="feature-box">
  158. <div class="w-1200 m-center pd-6 w">
  159. <img src="https://img.php.cn/upload/image/407/312/793/1638173840327201.gif" alt="">
  160. </div>
  161. </section>
  162. </div>
  163. <script>
  164. window.onload = function (){
  165. var top =document.getElementById('top')
  166. var myMain =document.getElementById('myMain')
  167. var nav = document.getElementById('nav')
  168. window.onscroll = function (){
  169. if (document.documentElement.scrollTop>=top.offsetHeight){
  170. nav.style.cssText="position:fixed;top:0px;";
  171. }else {
  172. nav.style.cssText="position:static;";
  173. myMain.style.marginTop ='0px';
  174. }
  175. }
  176. }
  177. </script>
  178. </body>
  179. </html>

图片占位

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post