|
51 | 51 | <button |
52 | 52 | v-if="productImages.length > 1" |
53 | 53 | @click="previousImage" |
54 | | - class="absolute left-0 sm:left-2 md:left-4 lg:left-8 xl:left-12 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-white/80 hover:bg-white border border-gray-200 flex items-center justify-center transition-colors shadow-sm z-10" |
| 54 | + class="absolute left-0 sm:left-2 md:left-4 lg:left-8 xl:left-12 top-1/2 -translate-y-1/2 w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-white/80 hover:bg-white border border-gray-200 flex items-center justify-center transition-colors shadow-sm z-10" |
55 | 55 | aria-label="上一张图片" |
56 | 56 | > |
57 | | - <Icon name="heroicons:chevron-left" class="w-6 h-6 text-black" /> |
| 57 | + <Icon name="heroicons:chevron-left" class="w-5 h-5 sm:w-6 sm:h-6 text-black" /> |
58 | 58 | </button> |
59 | 59 |
|
60 | 60 | <!-- 图片容器 --> |
61 | | - <div class="relative max-w-2xl w-full ml-12 mr-12 sm:ml-16 sm:mr-16 md:ml-20 md:mr-20" style="aspect-ratio: 4 / 3;"> |
| 61 | + <div class="relative w-full max-w-full md:max-w-2xl mx-auto px-2 sm:px-4 product-image-container"> |
62 | 62 | <!-- 主图 --> |
63 | 63 | <img |
64 | 64 | v-if="currentImage" |
|
93 | 93 | <button |
94 | 94 | v-if="productImages.length > 1" |
95 | 95 | @click="nextImage" |
96 | | - class="absolute right-0 sm:right-2 md:right-4 lg:right-8 xl:right-12 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-white/80 hover:bg-white border border-gray-200 flex items-center justify-center transition-colors shadow-sm z-10" |
| 96 | + class="absolute right-0 sm:right-2 md:right-4 lg:right-8 xl:right-12 top-1/2 -translate-y-1/2 w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-white/80 hover:bg-white border border-gray-200 flex items-center justify-center transition-colors shadow-sm z-10" |
97 | 97 | aria-label="下一张图片" |
98 | 98 | > |
99 | | - <Icon name="heroicons:chevron-right" class="w-6 h-6 text-black" /> |
| 99 | + <Icon name="heroicons:chevron-right" class="w-5 h-5 sm:w-6 sm:h-6 text-black" /> |
100 | 100 | </button> |
101 | 101 | </div> |
102 | 102 |
|
@@ -216,7 +216,13 @@ import { api } from '~/utils/api' |
216 | 216 | definePageMeta({ layout: 'page' }) |
217 | 217 | useHead({ |
218 | 218 | titleTemplate: '', |
219 | | - title: '商品详情 - 衣设服装设计' |
| 219 | + title: '商品详情 - 衣设服装设计', |
| 220 | + meta: [ |
| 221 | + { |
| 222 | + name: 'viewport', |
| 223 | + content: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' |
| 224 | + } |
| 225 | + ] |
220 | 226 | }) |
221 | 227 |
|
222 | 228 | const route = useRoute() |
@@ -378,3 +384,43 @@ watch(() => route.params.id, () => { |
378 | 384 | }, { immediate: true }) |
379 | 385 |
|
380 | 386 | </script> |
| 387 | + |
| 388 | +<style scoped> |
| 389 | +/* 默认移动端使用 1:1,提升可视面积;md 及以上使用 4:3 */ |
| 390 | +.product-image-container { |
| 391 | + aspect-ratio: 1 / 1; |
| 392 | +} |
| 393 | +
|
| 394 | +@media (min-width: 768px) { |
| 395 | + .product-image-container { |
| 396 | + aspect-ratio: 4 / 3; |
| 397 | + } |
| 398 | +} |
| 399 | +
|
| 400 | +/* 减少双击缩放触发几率 */ |
| 401 | +.product-image-container, .product-image-container img { |
| 402 | + touch-action: manipulation; |
| 403 | +} |
| 404 | +</style> |
| 405 | + |
| 406 | +<!-- global styles to mitigate fast-scroll header gap --> |
| 407 | +<style> |
| 408 | +html, body { |
| 409 | + background-color: #ffffff; |
| 410 | + overscroll-behavior-y: contain; /* reduce rubber-band over-scroll revealing gaps */ |
| 411 | + overscroll-behavior-x: none; |
| 412 | +} |
| 413 | +
|
| 414 | +/* Ensure the app header stays on its own compositing layer */ |
| 415 | +header, .site-header, .app-header { |
| 416 | + backface-visibility: hidden; |
| 417 | + transform: translateZ(0); |
| 418 | + will-change: transform; |
| 419 | + background-color: #ffffff; /* avoid transparent flash */ |
| 420 | +} |
| 421 | +
|
| 422 | +/* Respect safe area and avoid a visual seam on iOS */ |
| 423 | +header, .site-header, .app-header { |
| 424 | + padding-top: max(env(safe-area-inset-top), 0px); |
| 425 | +} |
| 426 | +</style> |
0 commit comments