/* 图片容器:100vw宽,最小宽度1440px,按图片原始比例(2560:1857)定高 */ .zoom-container { width: 7.5rem; height: 6.05rem; position: relative; } /* 图片包裹层:与容器同尺寸,定位参考系,承接缩放变换 */ .img-wrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; /* z-index: -10; */ } /* 图片:按原始比例填充包裹层,不裁切,初始放大+过渡动画 */ .bg-img { width: 7.5rem; height: 6.05rem; 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: #fff; 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: 0.01rem; height: 0; bottom: calc(100% + 6px); background-color: #fff; transition: height 0.8s ease; transform-origin: bottom center; } /* 向上延伸的标注线条(给需要向上的.annotation加anno-up类) */ .annotation.anno-up span::before { /* 把线条位置从文字下方,改成文字上方 */ bottom: auto; top: 0.3rem; /* 定位到文字顶部外 */ /* 线条方向改为向上延伸 */ transform-origin: top center; } .annotation.anno-up1 span::before { /* 把线条位置从文字下方,改成文字上方 */ bottom: auto; top: 0.5rem; /* 定位到文字顶部外 */ /* 线条方向改为向上延伸 */ transform-origin: top center; } /* 标注显示时,设置线条最终高度 */ .annotation.anno-show span::before { height: 0.57rem; } .zoom-t { width: 100%; text-align: center; font-size: 0.48rem; color: #fff; padding-top: 1.5rem; } .zoom-p { width: 100%; text-align: center; font-size: 0.20rem; color: #cbcfd8; position: absolute; top: 0.37rem; z-index: 10; line-height: 1.5; font-family: 'HarmonyOS-Light'; } /* 标注延迟类 */ .anno-delay-1 { transition-delay: 0.8s; } .anno-delay-1 span::before { transition-delay: 0.8s; }