affix.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <div class="affix">
  3. <avue-affix id="avue-view">
  4. <span class="affix-affix">固定在最顶部</span>
  5. </avue-affix>
  6. <div class="affix-line"></div>
  7. <avue-affix id="avue-view"
  8. :offset-top="50">
  9. <span class="affix-affix">固定在距离顶部 50px 的位置</span>
  10. </avue-affix>
  11. <div class="affix-line"></div>
  12. <avue-affix id="avue-view"
  13. :offset-top="100">
  14. <span class="affix-affix">固定在距离顶部 100px 的位置</span>
  15. </avue-affix>
  16. <div class="affix-line"></div>
  17. <avue-affix id="avue-view"
  18. :offset-top="150">
  19. <span class="affix-affix">固定在距离顶部 150px 的位置</span>
  20. </avue-affix>
  21. <div style="height:2000px;">
  22. <div style="padding:15px 20px;font-size:18px;">往下拉就会出现图钉</div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. export default {};
  28. </script>
  29. <style lang="scss">
  30. .affix {
  31. position: relative;
  32. background-color: #fff;
  33. &-affix {
  34. display: inline-block;
  35. color: #fff;
  36. padding: 10px 30px;
  37. text-align: center;
  38. background: rgba(0, 153, 229, 0.9);
  39. }
  40. &-line {
  41. height: 100px;
  42. }
  43. }
  44. </style>