siteBar.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <div class="site-bar">
  3. <div class="btn wechat">
  4. <svg-icon icon-class="wechat" />
  5. <img class="show-img" :src="wechatSrc" alt="">
  6. </div>
  7. <div class="btn top" @click="toTop" >
  8. <svg-icon icon-class="top" />
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. // 网页侧边栏小工具
  14. export default {
  15. name: "siteBar",
  16. props:{
  17. lang: {
  18. type: String,
  19. default: 'cn'
  20. },
  21. wechatSrc: {
  22. type: String,
  23. default: ''
  24. }
  25. },
  26. methods: {
  27. toTop() {
  28. // 缓慢移动到顶部
  29. window.scrollTo({
  30. top: 0,
  31. behavior: "smooth"
  32. });
  33. }
  34. }
  35. }
  36. </script>
  37. <style scoped>
  38. .site-bar{
  39. width: 50px;
  40. height: auto;
  41. position: fixed;
  42. right: 180px;
  43. top: 70%;
  44. transform: translateY(-50%);
  45. }
  46. .site-bar .btn{
  47. width: 50px;
  48. height: 50px;
  49. display: flex;
  50. justify-content: center;
  51. align-items: center;
  52. font-size: 2rem;
  53. cursor: pointer;
  54. background-color: #f5f5f5;
  55. border-radius: 50%;
  56. box-shadow: 0 0 5px #dedede;
  57. color: #999999;
  58. margin-bottom: 10px;
  59. }
  60. .site-bar .btn:hover{
  61. background-color: #dedede;
  62. color: #af4141;
  63. }
  64. .wechat{
  65. position: relative;
  66. }
  67. .wechat .show-img{
  68. position: absolute;
  69. bottom: 50px;
  70. right: 50px;
  71. display: block;
  72. width: 0;
  73. height: 0;
  74. max-width: none;
  75. border-radius: 5px;
  76. box-shadow: 1px 1px 7px 5px #dedede;
  77. opacity: 0;
  78. transition: all 0.5s;
  79. }
  80. .wechat:hover .show-img{
  81. opacity: 1;
  82. width: 180px;
  83. height: 180px;
  84. }
  85. </style>