banner.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="common-banner" :style="{'height': height + 'px', backgroundImage: `url(${img})`}">
  3. <!-- <img class="bg-img" :src="img" :style="{'height': height + 'px', 'max-height': height + 'px'}" alt="" srcset=""> -->
  4. <!-- <img class="bg-img" :src="img" alt="" srcset=""> -->
  5. <div class="bg-content">
  6. <slot></slot>
  7. </div>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. props: {
  13. img: {
  14. type: String,
  15. default: ''
  16. },
  17. height: {
  18. type: Number,
  19. default: 521
  20. }
  21. },
  22. data() {
  23. return {
  24. // bannerImg: require('~/assets/images/products/product_banner.png')
  25. }
  26. }
  27. }
  28. </script>
  29. <style lang="scss">
  30. .common-banner {
  31. // height: 521px;
  32. position: relative;
  33. margin: 0 auto;
  34. overflow: hidden;
  35. text-align: center;
  36. max-width: 2560px;
  37. background-size: cover;
  38. // max-width: 1920px;
  39. .bg-img {
  40. position: absolute;
  41. top: 0px;
  42. left: 50%;
  43. bottom: 0px;
  44. right: 0px;
  45. z-index: 1;
  46. -webkit-transform: translateX(-50%);
  47. transform: translateX(-50%);
  48. max-width: 2560px;
  49. // max-height: 521px;
  50. // height: 521px;
  51. display: block;
  52. }
  53. .bg-content {
  54. position: absolute;
  55. top: 0;
  56. z-index: 10;
  57. height: 100%;
  58. width: 100%;
  59. background: rgba(13, 92, 250, 0.8);
  60. }
  61. h2 {
  62. position: absolute;
  63. top: 50%;
  64. left: 50%;
  65. transform: translate(-50%, -50%);
  66. font-size: 66px;
  67. font-family: PingFangSC-Medium, PingFang SC;
  68. font-weight: 500;
  69. color: #FFFFFF;
  70. z-index: 10;
  71. }
  72. h4 {
  73. position: absolute;
  74. top: 50%;
  75. left: 50%;
  76. transform: translate(-50%, -50%);
  77. font-size: 18px;
  78. font-family: PingFangSC-Regular, PingFang SC;
  79. font-weight: 400;
  80. color: #FFFFFF;
  81. line-height: 25px;
  82. z-index: 10;
  83. margin-top: 82px;
  84. }
  85. }
  86. .content-wrap {
  87. margin-top: 85px;
  88. width: 100%;
  89. position: absolute;
  90. z-index: 10;
  91. .content {
  92. display: flex;
  93. justify-content: space-between;
  94. align-items: center;
  95. }
  96. .title {
  97. width: 396px;
  98. height: 92px;
  99. font-size: 66px;
  100. font-family: PingFangSC-Medium, PingFang SC;
  101. font-weight: 500;
  102. color: #FFFFFF;
  103. line-height: 92px;
  104. }
  105. }
  106. </style>