美化processbar
This commit is contained in:
@@ -168,49 +168,53 @@
|
||||
display: flex;
|
||||
flex-direction: row; /* 使子框横向排列 */
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
gap: 2px; /* 进度条之间的间距 */
|
||||
}
|
||||
|
||||
.progress-title {
|
||||
height: 60px;
|
||||
text-align: center;
|
||||
line-height: 60px;
|
||||
margin-right: 2px;
|
||||
border: 1px solid #ddd;
|
||||
transition: background-color 0.3s ease;
|
||||
height: 8px; /* 更细的进度条 */
|
||||
flex: 1; /* 均匀分配宽度 */
|
||||
border-radius: 4px; /* 圆角设计,更扁平化 */
|
||||
transition: all 0.3s ease; /* 平滑过渡效果 */
|
||||
position: relative;
|
||||
|
||||
/* 新增以下属性实现文字溢出省略 */
|
||||
white-space: nowrap; /* 防止文字换行 */
|
||||
overflow: hidden; /* 隐藏溢出内容 */
|
||||
text-overflow: ellipsis; /* 溢出部分显示为省略号 */
|
||||
cursor: pointer;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1); /* 轻微阴影,增加层次感 */
|
||||
overflow: visible; /* 允许文字溢出 */
|
||||
}
|
||||
|
||||
/* 颜色方案:已学习为蓝色,当前学习为绿色,未学习为白色 */
|
||||
.blue {
|
||||
background-color: #007bff; /* 蓝色 - 已学习 */
|
||||
}
|
||||
|
||||
.green {
|
||||
background-color: green;
|
||||
color: white;
|
||||
background-color: #28a745; /* 绿色 - 当前学习 */
|
||||
}
|
||||
|
||||
.white {
|
||||
background-color: white;
|
||||
color: black;
|
||||
background-color: #e9ecef; /* 浅灰色 - 未学习,比纯白色更美观 */
|
||||
}
|
||||
|
||||
.progress-box > .progress-title:last-child {
|
||||
margin-bottom: 0; /* 防止最后一个子框出现多余的间距 */
|
||||
/* 进度条悬停效果 */
|
||||
.progress-title:hover {
|
||||
transform: translateY(-1px); /* 轻微上浮效果 */
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* 增强阴影 */
|
||||
}
|
||||
|
||||
/* 进度条详细信息的样式 */
|
||||
#progress-detail {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: none;
|
||||
padding: 10px;
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
border-radius: 6px;
|
||||
max-width: 200px;
|
||||
font-size: 14px;
|
||||
z-index: 1000;
|
||||
pointer-events: none; /* 防止干扰鼠标事件 */
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.3); /* 增强阴影 */
|
||||
}
|
||||
|
||||
.button {
|
||||
|
||||
@@ -469,35 +469,38 @@ function generateProgressBar(N, idx, titles) {
|
||||
// 获取详细信息容器
|
||||
const detailBox = document.getElementById('progress-detail');
|
||||
|
||||
// 根据N值动态调整每个进度节点的宽度
|
||||
const nodeWidth = 100 / N; // 每个节点的宽度为 100% / N
|
||||
|
||||
// 根据N值生成子框并设置颜色
|
||||
for (let i = 0; i < N; i++) {
|
||||
const titleBox = document.createElement('div');
|
||||
titleBox.className = 'progress-title';
|
||||
|
||||
// 设置进度条的颜色
|
||||
// 设置进度条的颜色:已学习为蓝色,当前学习为绿色,未学习为白色
|
||||
if (i < idx) {
|
||||
titleBox.classList.add('green'); // 已完成部分
|
||||
titleBox.classList.add('blue'); // 已完成部分 - 蓝色
|
||||
} else if (i === idx) {
|
||||
titleBox.classList.add('green'); // 当前正在学习 - 绿色
|
||||
} else {
|
||||
titleBox.classList.add('white'); // 未完成部分
|
||||
titleBox.classList.add('white'); // 未完成部分 - 白色
|
||||
}
|
||||
|
||||
// 设置每个子框的标题
|
||||
titleBox.innerHTML = titles[i] || `Step ${i + 1}`;
|
||||
|
||||
// 设置每个进度节点的宽度
|
||||
titleBox.style.width = `${nodeWidth}%`;
|
||||
// 移除进度条上的文字,因为现在进度条很细
|
||||
titleBox.innerHTML = '';
|
||||
|
||||
// 监听鼠标移入事件来显示详情
|
||||
titleBox.addEventListener('mouseenter', function () {
|
||||
detailBox.innerHTML = `Step ${i + 1}: ${titles[i] || "No title"}`;// - Additional details here...`;
|
||||
detailBox.innerHTML = `Step ${i + 1}: ${titles[i] || "No title"}`;
|
||||
detailBox.style.display = 'block';
|
||||
// 根据进度条位置显示详情
|
||||
const rect = titleBox.getBoundingClientRect();
|
||||
detailBox.style.top = `${rect.top + window.scrollY - 100}px`; // 微调位置
|
||||
detailBox.style.top = `${rect.top + window.scrollY - 10}px`; // 调整位置到进度条上方
|
||||
detailBox.style.left = `${rect.left + window.scrollX + rect.width / 2 - detailBox.offsetWidth / 2}px`;
|
||||
// 确保详情框不会超出视口
|
||||
if (detailBox.getBoundingClientRect().left < 0) {
|
||||
detailBox.style.left = '10px';
|
||||
}
|
||||
if (detailBox.getBoundingClientRect().right > window.innerWidth) {
|
||||
detailBox.style.left = `${window.innerWidth - detailBox.offsetWidth - 10}px`;
|
||||
}
|
||||
});
|
||||
|
||||
// 监听鼠标移出事件来隐藏详情
|
||||
|
||||
Reference in New Issue
Block a user