/* 图片容器:100vw宽,最小宽度1440px,按图片原始比例(2560:1857)定高 */ .zoom-container { width: 100%; min-width: 1440px; overflow: hidden; position: relative; /* 固定比例:高度 = 宽度 * 1857/2560,确保图片不裁切 */ aspect-ratio: 2560 / 1857; height: auto; /* 替代原max计算,用aspect-ratio保证比例 */ } /* 图片包裹层:与容器同尺寸,定位参考系,承接缩放变换 */ .img-wrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; } /* 图片:按原始比例填充包裹层,不裁切,初始放大+过渡动画 */ .bg-img { width: 100%; height: 100%; object-fit: contain; /* 改为contain,确保图片完整显示,不裁切 */ display: block; transform: scale(1.5); transition: transform 1.8s ease; transform-origin: center center; } /* 图片缩小后的状态 */ .bg-img.zoom-out { transform: scale(1); } /* 标注样式:关键修正 - 基于容器绝对定位,百分比参考图片原始比例 */ .annotation { position: absolute; color: #48494D; font-size: calc(12px + 0.3vw); opacity: 0; transform: translateY(calc(10px + 0.5vw)); transition: opacity 0.8s ease, transform 0.8s ease; pointer-events: none; z-index: 10; white-space: nowrap; /* 关键:标注的定位参考系是容器(与图片同比例),而非缩放后的图片 */ top: 0; left: 0; /* 重置默认值,依赖内联style的百分比定位 */ } /* 标注显示状态 */ .annotation.anno-show { opacity: 1; transform: translateY(0); } .annotation span { position: relative; display: inline-block; /* 确保文字居中对齐 */ text-align: center; } /* 标注线条样式:基于文字定位,适配缩放 */ .annotation span::before { content: ''; position: absolute; left: 50%; transform: translateX(-50%); width: 1px; height: 0; bottom: calc(100% + 6px); background-color: #48494D; transition: height 0.8s ease; transform-origin: bottom center; } /* 标注显示时,设置线条最终高度 */ .annotation.anno-show span::before { height:clamp(50px,3vw,0.6rem); /* 最终高度(vw单位) */ } /* 响应式适配:1280px以下固定尺寸 */ @media (max-width: 1280px) { .zoom-container { min-width: 1280px; /* 最小宽度适配 */ } .annotation span::before { bottom: calc(100% + 6px); } .annotation.anno-show span::before { height: 38px; /* 固定高度 */ } .annotation { font-size: 14px; /* 固定字体大小,避免过小 */ } } /* 标注延迟类 */ .anno-delay-1 { transition-delay: 0.8s; } .anno-delay-1 span::before { transition-delay: 0.8s; }