index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="item" @click="handleClick(item)">
  3. <div class="card-img">
  4. <img class="full" :src="item.thumb" alt="" />
  5. <img class="real" :src="item.thumb" alt="" />
  6. </div>
  7. <div class="card-txt">
  8. <div class="title">
  9. <span :title="item.name">{{ item.name }}</span>
  10. </div>
  11. <div class="tag">
  12. <span :title="item.material">{{ item.material }}</span>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import browser from "@/utils/browser.js";
  19. export default {
  20. props: ["item"],
  21. data() {
  22. return {
  23. isMobile: browser.mobile
  24. };
  25. },
  26. methods:{
  27. handleClick(item){
  28. this.$emit('handleItem',item)
  29. }
  30. }
  31. };
  32. </script>
  33. <style lang="less" scoped>
  34. @margin: 36px;
  35. .item {
  36. text-align: center;
  37. display: inline-block;
  38. width: calc((100% - @margin * 3) / 4);
  39. margin-right: @margin;
  40. margin-bottom: @margin;
  41. background: #f5ede2;
  42. border-radius: 8px;
  43. overflow: hidden;
  44. cursor: pointer;
  45. &:nth-of-type(4n) {
  46. margin-right: 0;
  47. }
  48. .card-img {
  49. width: 310px;
  50. height: 190px;
  51. position: relative;
  52. max-height: 190px;
  53. overflow: hidden;
  54. img {
  55. width: 100%;
  56. }
  57. .full {
  58. opacity: 0;
  59. }
  60. .real {
  61. position: absolute;
  62. z-index: 99;
  63. top: 50%;
  64. left: 50%;
  65. transform: translate(-50%, -50%);
  66. }
  67. }
  68. .card-txt {
  69. display: flex;
  70. justify-content: space-between;
  71. align-items: center;
  72. font-size: 16px;
  73. padding: 8px 10px;
  74. .tag {
  75. color: @theme;
  76. }
  77. div{
  78. overflow: hidden;
  79. text-overflow:ellipsis;
  80. white-space: nowrap;
  81. }
  82. }
  83. }
  84. @media screen and (min-width: 500px) and (max-width: 1400px) {
  85. .item {
  86. width: calc((100% - @margin * 3) / 3);
  87. &:nth-of-type(3n) {
  88. margin-right: 0;
  89. }
  90. &:nth-of-type(4n){
  91. margin-right: @margin;
  92. }
  93. }
  94. }
  95. @media screen and (max-width: 500px) {
  96. .item {
  97. width: 42.4vw;
  98. margin-right: 5vw;
  99. margin-bottom: 5vw;
  100. &:nth-of-type(2n) {
  101. margin-right: 0;
  102. }
  103. // &:nth-of-type(4n){
  104. // margin-right: @margin;
  105. // }
  106. }
  107. }
  108. </style>