task-comp2.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>卡片组示例</title>
  5. <style>
  6. .card-container {
  7. display: flex;
  8. flex-wrap: wrap;
  9. }
  10. .card {
  11. width: 300px;
  12. margin: 10px;
  13. border: 1px solid #ccc;
  14. border-radius: 5px;
  15. padding: 10px;
  16. box-sizing: border-box;
  17. text-align: center;
  18. }
  19. .card img {
  20. width: 100%;
  21. height: auto;
  22. border-radius: 5px;
  23. margin-bottom: 10px;
  24. }
  25. .card p {
  26. margin: 0;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div id="app">
  32. <div class="card-container">
  33. <div v-for="card in cards" class="card">
  34. <img :src="card.image" alt="Card Image">
  35. <p>{{ card.text }}</p>
  36. </div>
  37. </div>
  38. </div>
  39. <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
  40. <script>
  41. new Vue({
  42. el: '#app',
  43. data: {
  44. cards: [
  45. {
  46. image: '1.png',
  47. text: '布偶猫'
  48. },
  49. {
  50. image: '2.png',
  51. text: '幼猫'
  52. },
  53. {
  54. image: '3.png',
  55. text: '健康宠物猫'
  56. }
  57. ]
  58. }
  59. });
  60. </script>
  61. </body>
  62. </html>