banner.vue 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div class="common-banner" :style="{'height': height + 'px'}">
  3. <img class="bg-img" :src="img" :style="{'height': height + 'px', 'max-height': height + 'px'}" alt="" srcset="">
  4. <slot></slot>
  5. </div>
  6. </template>
  7. <script>
  8. export default {
  9. props: {
  10. img: {
  11. type: String,
  12. default: ''
  13. },
  14. height: {
  15. type: Number,
  16. default: 521
  17. }
  18. },
  19. data() {
  20. return {
  21. // bannerImg: require('~/assets/images/products/product_banner.png')
  22. }
  23. }
  24. }
  25. </script>
  26. <style lang="scss">
  27. .common-banner {
  28. width: 100%;
  29. // height: 521px;
  30. position: relative;
  31. margin: 0 auto;
  32. overflow: hidden;
  33. text-align: center;
  34. .bg-img {
  35. position: absolute;
  36. top: 0px;
  37. left: 50%;
  38. bottom: 0px;
  39. right: 0px;
  40. z-index: 1;
  41. -webkit-transform: translateX(-50%);
  42. transform: translateX(-50%);
  43. max-width: 2560px;
  44. // max-height: 521px;
  45. // height: 521px;
  46. display: block;
  47. }
  48. }
  49. </style>