'commit'
This commit is contained in:
@@ -10,15 +10,13 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.background-container {
|
.background-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
flex: 1;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-image: url('D:\\dsWork\\dsProject\\dsLightRag\\XingJun\\background.png');
|
background-image: url('D:\\dsWork\\dsProject\\dsLightRag\\XingJun\\background.png');
|
||||||
background-position: center;
|
background-position: center;
|
||||||
@@ -27,64 +25,156 @@
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 控制面板样式 */
|
||||||
|
.control-panel {
|
||||||
|
width: 200px;
|
||||||
|
background-color: #fff;
|
||||||
|
border-left: 1px solid #ccc;
|
||||||
|
padding: 20px;
|
||||||
|
height: 100vh;
|
||||||
|
box-sizing: border-box;
|
||||||
|
z-index: 2;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-section {
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-section h3 {
|
||||||
|
margin-top: 0;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 图片选择按钮样式 */
|
||||||
|
.image-selector {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-btn {
|
||||||
|
width: 70px;
|
||||||
|
height: 70px;
|
||||||
|
border: 2px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: all 0.2s;
|
||||||
|
background-size: contain;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-btn:hover {
|
||||||
|
border-color: #4CAF50;
|
||||||
|
transform: scale(1.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-btn:active {
|
||||||
|
transform: scale(0.98);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 箭头图片样式 */
|
||||||
|
.arrow-image {
|
||||||
|
position: absolute;
|
||||||
|
width: 155px;
|
||||||
|
height: 173px;
|
||||||
|
background-size: contain;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
z-index: 2;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="background-container">
|
<div class="background-container">
|
||||||
<!-- 1.png 图片 -->
|
</div>
|
||||||
<div
|
|
||||||
class="red-arrow"
|
<!-- 右侧控制面板 -->
|
||||||
style="
|
<div class="control-panel">
|
||||||
position: absolute;
|
<div class="control-section">
|
||||||
top: 10%;
|
<h3>增加箭头</h3>
|
||||||
left: 10%;
|
<div class="image-selector">
|
||||||
transform: translate(-50%,-50%);
|
<div class="image-btn" data-image="./1.png" style="background-image: url('./1.png');"></div>
|
||||||
z-index: 2;
|
<div class="image-btn" data-image="./2.png" style="background-image: url('./2.png');"></div>
|
||||||
width: 155px;
|
<div class="image-btn" data-image="./3.png" style="background-image: url('./3.png');"></div>
|
||||||
height: 173px;
|
<div class="image-btn" data-image="./4.png" style="background-image: url('./4.png');"></div>
|
||||||
background-image: url('./1.png');
|
<div class="image-btn" data-image="./5.png" style="background-image: url('./5.png');"></div>
|
||||||
background-size: contain;
|
</div>
|
||||||
background-repeat: no-repeat;
|
|
||||||
">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 新增2.png 图片 -->
|
|
||||||
<div
|
|
||||||
class="red-arrow"
|
|
||||||
style="
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%,-50%);
|
|
||||||
z-index: 2;
|
|
||||||
width: 155px;
|
|
||||||
height: 173px;
|
|
||||||
background-image: url('./2.png');
|
|
||||||
background-size: contain;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 新增3.png 图片 -->
|
|
||||||
<div
|
|
||||||
class="red-arrow"
|
|
||||||
style="
|
|
||||||
position: absolute;
|
|
||||||
top: 90%;
|
|
||||||
left: 90%;
|
|
||||||
transform: translate(-50%,-50%);
|
|
||||||
z-index: 2;
|
|
||||||
width: 155px;
|
|
||||||
height: 173px;
|
|
||||||
background-image: url('./3.png');
|
|
||||||
background-size: contain;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 获取DOM元素
|
||||||
|
const backgroundContainer = document.querySelector('.background-container');
|
||||||
|
const imageButtons = document.querySelectorAll('.image-btn');
|
||||||
|
|
||||||
|
// 为每个图片按钮添加点击事件
|
||||||
|
imageButtons.forEach(button => {
|
||||||
|
button.addEventListener('click', () => {
|
||||||
|
const imagePath = button.getAttribute('data-image');
|
||||||
|
addImageToContainer(imagePath);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 添加图片到主区域
|
||||||
|
function addImageToContainer(imagePath) {
|
||||||
|
// 创建新的图片元素
|
||||||
|
const newImage = document.createElement('div');
|
||||||
|
newImage.className = 'arrow-image';
|
||||||
|
newImage.style.backgroundImage = `url('${imagePath}')`;
|
||||||
|
|
||||||
|
// 设置初始位置(随机位置)
|
||||||
|
const containerRect = backgroundContainer.getBoundingClientRect();
|
||||||
|
const x = Math.random() * (containerRect.width - 155);
|
||||||
|
const y = Math.random() * (containerRect.height - 173);
|
||||||
|
|
||||||
|
newImage.style.left = `${x}px`;
|
||||||
|
newImage.style.top = `${y}px`;
|
||||||
|
|
||||||
|
// 添加到容器
|
||||||
|
backgroundContainer.appendChild(newImage);
|
||||||
|
|
||||||
|
// 可选:添加拖拽功能
|
||||||
|
makeElementDraggable(newImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使元素可拖拽
|
||||||
|
function makeElementDraggable(element) {
|
||||||
|
let isDragging = false;
|
||||||
|
let offsetX, offsetY;
|
||||||
|
|
||||||
|
element.addEventListener('mousedown', startDrag);
|
||||||
|
element.addEventListener('mousemove', drag);
|
||||||
|
element.addEventListener('mouseup', endDrag);
|
||||||
|
element.addEventListener('mouseleave', endDrag);
|
||||||
|
|
||||||
|
function startDrag(e) {
|
||||||
|
isDragging = true;
|
||||||
|
const rect = element.getBoundingClientRect();
|
||||||
|
offsetX = e.clientX - rect.left;
|
||||||
|
offsetY = e.clientY - rect.top;
|
||||||
|
element.style.zIndex = '10';
|
||||||
|
}
|
||||||
|
|
||||||
|
function drag(e) {
|
||||||
|
if (!isDragging) return;
|
||||||
|
e.preventDefault();
|
||||||
|
const x = e.clientX - offsetX;
|
||||||
|
const y = e.clientY - offsetY;
|
||||||
|
element.style.left = `${x}px`;
|
||||||
|
element.style.top = `${y}px`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function endDrag() {
|
||||||
|
isDragging = false;
|
||||||
|
element.style.zIndex = '2';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user