fix: 优化背景图滑动逻辑,确保居中显示、左右滑动完整,全内容可拖动到预览区

This commit is contained in:
Zhukj
2026-04-15 15:42:58 +08:00
parent e377aaf73c
commit c54050ff79
4 changed files with 313 additions and 93 deletions

View File

@@ -66,12 +66,24 @@ html, body {
position: relative;
}
/* 空提示 - 移到预览白板中 */
.empty-tip {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #999;
font-size: 14px;
text-align: center;
pointer-events: none;
z-index: 5;
}
/* 预览区域固定 3:5 比例,打开即显示空白面板 */
.preview {
overflow: hidden;
}
.image-container {
display: flex;
position: relative;
@@ -81,6 +93,9 @@ html, body {
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
background: #fff;
overflow: hidden;
touch-action: pan-x;
margin: 0 auto;
contain: layout style paint;
}
.image-container.empty {
@@ -88,13 +103,40 @@ html, body {
border: 2px dashed #ddd;
}
/* 背景图自适应铺满容器,超出部分裁剪 */
#bgImage {
display: block;
/* 背景图层 - 用于滑动调整位置,溢出隐藏 */
.preview-bg-layer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
overflow: hidden;
}
/* 输入框图层 - 与背景图层隔离 */
.preview-input-layer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
/* 输入框可交互 */
.preview-input-layer .text-input {
pointer-events: auto;
}
/* 背景图 - 保持比例,可滑动调整位置 */
#bgImage {
display: block;
position: absolute;
height: 100%;
width: auto;
max-width: none;
left: 50%;
transform: translateX(-50%);
-webkit-user-drag: none;
}
@@ -102,14 +144,15 @@ html, body {
display: none;
}
/* 文字输入框 - 透明无边框设计 */
/* 文字输入框 - 透明无边框设计,黑色微软雅黑16px */
.text-input {
position: absolute;
min-width: 80px;
min-height: 32px;
padding: 4px 8px;
font-size: 18px;
color: #333;
font-size: 16px;
color: #000;
font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
background: transparent;
border: 2px solid transparent;
border-radius: 4px;
@@ -120,6 +163,11 @@ html, body {
-webkit-user-select: none;
user-select: none;
transition: border-color 0.2s;
z-index: 10;
/* 确保输入框内容超出时不影响父容器和其他元素 */
overflow: visible;
max-width: none;
box-sizing: border-box;
}
/* 选中状态(单击/长按) - 仅显示虚线边框 */