ImageTitleBlock.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div
  3. :class="[
  4. 'ImageTitleBlock',
  5. title ? 'has-title' : '',
  6. fit? 'fit' : ''
  7. ]"
  8. :style="{ backgroundImage: `url('${image}')` }"
  9. @click="$emit('click')"
  10. >
  11. <div class="desc">
  12. <h5>{{ title }}</h5>
  13. <p>{{ desc }}</p>
  14. </div>
  15. </div>
  16. </template>
  17. <script setup lang="ts">
  18. defineProps({
  19. title: {
  20. type: String,
  21. default: ''
  22. },
  23. desc: {
  24. type: String,
  25. default: '' ,
  26. },
  27. image: {
  28. type: String,
  29. default: ''
  30. },
  31. fit: {
  32. type: Boolean,
  33. default: false
  34. }
  35. })
  36. defineEmits([
  37. 'click',
  38. ])
  39. </script>
  40. <style lang="scss">
  41. @use '@/assets/scss/colors.scss' as *;
  42. .ImageTitleBlock {
  43. position: relative;
  44. padding: 24px;
  45. background-size: cover;
  46. background-position: top center;
  47. width: 400px;
  48. height: 270px;
  49. margin-right: 24px;
  50. &.fit {
  51. width: 100%;
  52. margin-right: 0;
  53. }
  54. &.has-title {
  55. &::before {
  56. content: '';
  57. display: block;
  58. position: absolute;
  59. right: 0;
  60. left: 0;
  61. bottom: 0;
  62. height: 120px;
  63. background: linear-gradient(
  64. 180deg,
  65. rgba(#000, 0) 0%,
  66. rgba(#000, 0.7) 100%
  67. )
  68. }
  69. }
  70. .desc {
  71. position: absolute;
  72. right: 0;
  73. left: 0;
  74. bottom: 0;
  75. display: flex;
  76. flex-direction: column;
  77. padding: 24px;
  78. color: #fff;
  79. h5 {
  80. font-family: SourceHanSerifCNBold;
  81. font-size: 1.1rem;
  82. margin-bottom: 5px;
  83. }
  84. p {
  85. font-size: 0.8rem;
  86. margin: 0;
  87. }
  88. }
  89. }
  90. </style>