index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template >
  2. <div class="border-panel" :style="borderPanelStyle">
  3. <div class="border-panel_header" :style="{
  4. backgroundImage: `url(${headerImageBgUrl})`
  5. }" >
  6. <div class="title" :data-text="title">{{title}}</div>
  7. </div>
  8. <div class="border-panel_content">
  9. <slot></slot>
  10. </div>
  11. </div>
  12. </template>
  13. <script >
  14. import { headerTitleBgs } from './data'
  15. /**
  16. * 边框面板
  17. */
  18. export default {
  19. name: "BorderPanel",
  20. props: {
  21. title: {
  22. type: String,
  23. default: "标题"
  24. },
  25. width: {
  26. type: String,
  27. default: '443px'
  28. },
  29. height: {
  30. type: String,
  31. default: '200px'
  32. },
  33. headerType: {
  34. type: Number,
  35. default: 0
  36. }
  37. },
  38. computed: {
  39. borderPanelStyle: function () {
  40. return {
  41. "--height": this.$props.height,
  42. "--width": this.$props.width,
  43. '--header-ops': ['-4px', '0px'][this.$props.headerType]
  44. }
  45. },
  46. headerImageBgUrl: function() {
  47. return headerTitleBgs[this.$props.headerType]
  48. }
  49. }
  50. }
  51. </script>
  52. <style scoped>
  53. .border-panel {
  54. position: relative;
  55. height: var(--height);
  56. width: var(--width);
  57. box-sizing: border-box;
  58. /* background: linear-gradient(360deg, #0c5a87 0%, rgba(0, 163, 255, 0) 100%); */
  59. background: linear-gradient(360deg, rgba(0, 133, 255, 0.25) 0%, rgba(0, 163, 255, 0) 100%);
  60. }
  61. .border-panel_header{
  62. height: 50px;
  63. width: var(--width);
  64. background-image: url('../assets/border-panel_header_1.svg');
  65. background-repeat: no-repeat;
  66. background-position: var(--header-ops) 0px;
  67. }
  68. .border-panel_header .title {
  69. position: relative;
  70. color: #95CCFF;
  71. font-size: 24px;
  72. line-height: 24px;
  73. top: 11px;
  74. left: 35px;
  75. text-shadow: 0 1px 1px #0057FF;
  76. }
  77. .border-panel_header .title::after {
  78. content: attr(data-text);
  79. position: absolute;
  80. width: 100%;
  81. height: 100%;
  82. left: 0;
  83. top: 0;
  84. z-index: 1;
  85. color: #fff;
  86. -webkit-mask: linear-gradient(180deg, #95CCFF, transparent);
  87. }
  88. .border-panel::after {
  89. content: "";
  90. position: absolute;
  91. top: 0px;
  92. left: 0px;
  93. padding: 1px;
  94. box-sizing: border-box;
  95. width: var(--width);
  96. height: var(--height);
  97. background: linear-gradient(360deg, #0c5a87 0%, rgba(0, 163, 255, 0) 100%);
  98. /* 随便定义颜色 */
  99. --mask-bg: linear-gradient(red, red);
  100. --m-o: content-box, padding-box;
  101. /* mask允许使用者通过遮罩或者裁切特定区域的图片的方式来隐藏一个元素的部分或者全部可见区域 */
  102. /* 设置了用作元素蒙版层的图像,默认值为none,值为透明图片,或透明渐变 */
  103. -webkit-mask-image: var(--mask-bg), var(--mask-bg);
  104. /* 默认值为border-box,可选值与background-origin相同 */
  105. -webkit-mask-origin: var(--m-o);
  106. /* 默认值为border-box,可选值与background-clip相同 */
  107. -webkit-mask-clip: var(--m-o);
  108. /* exclude排除,只显示不重合的地方,Firefox支持4个属性 */
  109. mask-composite: exclude;
  110. /*只显示下方遮罩,重合的地方不显示*/
  111. -webkit-mask-composite: destination-out;
  112. }
  113. .border-panel_content {
  114. padding: 0px 1px 0px 1px;
  115. }
  116. </style>