index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div class="border-panel" :style="borderPanelStyle">
  3. <div
  4. class="border-panel_header"
  5. :style="{
  6. backgroundImage: `url(${headerImageBgUrl})`,
  7. }"
  8. >
  9. <linear-text
  10. :text="title"
  11. startColor="#95CCFF"
  12. endColor="#fff"
  13. :extClass="{
  14. top: '11px',
  15. left: '35px',
  16. textShadow: '0 1px 1px #0057FF',
  17. }"
  18. />
  19. </div>
  20. <div class="border-panel_content">
  21. <slot></slot>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import { headerTitleBgs } from "./data";
  27. import LinearText from "../LinearText";
  28. /**
  29. * 边框面板
  30. */
  31. export default {
  32. name: "BorderPanel",
  33. components: {
  34. LinearText,
  35. },
  36. props: {
  37. title: {
  38. type: String,
  39. default: "标题",
  40. },
  41. width: {
  42. type: String,
  43. default: "443px",
  44. },
  45. height: {
  46. type: String,
  47. default: "200px",
  48. },
  49. headerType: {
  50. type: Number,
  51. default: 0,
  52. },
  53. },
  54. computed: {
  55. borderPanelStyle: function () {
  56. return {
  57. "--height": this.$props.height,
  58. "--width": this.$props.width,
  59. "--header-ops": ["-4px", "0px"][this.$props.headerType],
  60. };
  61. },
  62. headerImageBgUrl: function () {
  63. return headerTitleBgs[this.$props.headerType];
  64. },
  65. },
  66. };
  67. </script>
  68. <style scoped>
  69. .border-panel {
  70. position: relative;
  71. height: var(--height);
  72. width: var(--width);
  73. box-sizing: border-box;
  74. /* background: linear-gradient(360deg, #0c5a87 0%, rgba(0, 163, 255, 0) 100%); */
  75. background: linear-gradient(
  76. 360deg,
  77. rgba(0, 133, 255, 0.25) 0%,
  78. rgba(0, 163, 255, 0) 100%
  79. );
  80. }
  81. .border-panel_header {
  82. height: 50px;
  83. width: var(--width);
  84. background-image: url("../assets/border-panel_header_1.svg");
  85. background-repeat: no-repeat;
  86. background-position: var(--header-ops) 0px;
  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>