侧边栏圆角动画
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 3s

This commit is contained in:
2026-04-16 11:03:14 +08:00
parent b269e18547
commit 53a317c8cf
2 changed files with 246 additions and 168 deletions

View File

@@ -62,7 +62,7 @@
{if condition="!empty($child.products)"} {if condition="!empty($child.products)"}
<div class="scroll-box"> <div class="scroll-box">
{volist name="$child.products" id="pro"} {volist name="$child.products" id="pro"}
<a class="card" href="{:url('product/detail', ['id' => $pro.id])}"> <a class="card" href="{:url('product/detail', ['id' => $pro.id])}" style="background: #fafafa;">
<div class="card-img"> <div class="card-img">
<img src="{$pro.cover_image}" alt=""> <img src="{$pro.cover_image}" alt="">
</div> </div>
@@ -116,5 +116,55 @@
back.addEventListener('click',()=>{ back.addEventListener('click',()=>{
window.location.href = document.referrer; window.location.href = document.referrer;
}) })
// 更新侧边栏相邻元素的圆角
function updateSidebarAdjacentRadius() {
const sidebarItems = document.querySelectorAll('.sidebar li');
// 先移除所有相邻类名
sidebarItems.forEach(item => {
item.classList.remove('active-prev', 'active-next');
});
// 找到当前激活的项
let activeIndex = -1;
sidebarItems.forEach((item, index) => {
if (item.classList.contains('active')) {
activeIndex = index;
}
});
// 添加上一个和下一个的类名使用requestAnimationFrame确保DOM更新
requestAnimationFrame(() => {
if (activeIndex > 0) {
sidebarItems[activeIndex - 1].classList.add('active-prev');
}
if (activeIndex < sidebarItems.length - 1) {
sidebarItems[activeIndex + 1].classList.add('active-next');
}
});
}
// 绑定点击事件
document.querySelectorAll('.sidebar li').forEach(item => {
item.addEventListener('click', function() {
// 移除所有active
document.querySelectorAll('.sidebar li').forEach(li => {
li.classList.remove('active');
});
// 添加active
this.classList.add('active');
// 更新相邻圆角
updateSidebarAdjacentRadius();
// 您的tab切换逻辑
// const tabId = this.getAttribute('data-tab');
// 切换内容...
});
});
// 页面初始化时调用
if (document.querySelector('.sidebar li.active')) {
updateSidebarAdjacentRadius();
}
</script> </script>
{/block} {/block}

View File

@@ -1,23 +1,24 @@
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
box-sizing: border-box; box-sizing: border-box;
font-family: sans-serif; font-family: sans-serif;
font-size: inherit !important; font-size: inherit !important;
/* font-size:100% !important; */ /* font-size:100% !important; */
} }
body { body {
background: #f5f5f5; background: #f5f5f5;
font-size: inherit !important; font-size: inherit !important;
/* font-size:100% !important; */ /* font-size:100% !important; */
height: 100vh; height: 100vh;
overflow: hidden overflow: hidden;
max-width: 100vw !important;
} }
.top-box { .top-box {
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
padding: 20px 22px; padding: 20px 22px;
@@ -25,9 +26,9 @@
margin-top: 46px; margin-top: 46px;
/* border-bottom: 1px solid #f0f0f0; */ /* border-bottom: 1px solid #f0f0f0; */
box-shadow: 0 2px 8px rgba(217, 217, 217, 0.2); box-shadow: 0 2px 8px rgba(217, 217, 217, 0.2);
} }
.top-bar { .top-bar {
display: flex; display: flex;
align-items: center; align-items: center;
height: 0.82rem; height: 0.82rem;
@@ -35,64 +36,77 @@
justify-content: space-between; justify-content: space-between;
border-radius: 0.2rem; border-radius: 0.2rem;
padding: 0 16px; padding: 0 16px;
} }
.back { .back {
width: 14px; width: 0.28rem;
height: 14px; height: 0.28rem;
color: #333; color: #333;
cursor: pointer; cursor: pointer;
display: flex; display: flex;
align-items: center; align-items: center;
} }
.back img {
.title { width: 0.28rem;
height: 0.28rem;
}
.title {
font-size: 0.32rem !important; font-size: 0.32rem !important;
font-weight: 500; font-weight: 500;
} }
/* 主体布局 */ /* 主体布局 */
.main { .main {
display: flex; display: flex;
height: calc(100% - 46px); height: calc(100% - 46px);
margin-top:0.018rem; margin-top:0.018rem;
} }
/* 左侧菜单 */ /* 左侧菜单 #FAFAFA;*/
.sidebar { .sidebar {
width: 114px; width: 114px;
background: #FAFAFA; background: #fff;
overflow-y: auto; overflow-y: auto;
box-sizing: border-box; box-sizing: border-box;
} }
.sidebar li { .sidebar li {
list-style: none; list-style: none;
padding: 24px 16px; padding: 24px 16px;
text-align: center; text-align: center;
font-size: 0.28rem !important; font-size: 0.28rem !important;
color: #686A70; color:#686A70; /* #686A70;*/
cursor: pointer; cursor: pointer;
} background:#FAFAFA;
/* 分别控制上下圆角的过渡 */
.sidebar li.active { border-top-right-radius: 0;
border-bottom-right-radius: 0;
transition: border-radius 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar li.active {
color: #004BFA; color: #004BFA;
background: #fff; background: #fff;
border-top-right-radius: 0.17rem; }
border-bottom-right-radius:0.17rem ;
}
/* 右侧内容 */
.right-content { .sidebar li.active-prev {
border-bottom-right-radius: 0.17rem !important;
}
.sidebar li.active-next {
border-top-right-radius: 0.17rem !important;
}
/* 右侧内容 */
.right-content {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
padding-left: 12px; padding-left: 12px;
background: #fff; background: #fff;
margin-bottom: 80px; margin-bottom: 80px;
} }
.sec-header { .sec-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@@ -101,40 +115,43 @@
padding-right: 17px; padding-right: 17px;
padding-bottom: 12px; padding-bottom: 12px;
} }
.sec-title { .sec-title {
font-size: 0.28rem !important; font-size: 0.28rem !important;
color: #686A70; color: #686A70;
font-weight: 500 font-weight: 500
} }
.sec-arrow { .sec-arrow {
width: 20px; width: 0.28rem;
height: 20px; height: 0.28rem;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
color: #666; color: #666;
font-size: 20px; font-size: 20px;
cursor: pointer; cursor: pointer;
} }
.sec-arrow img {
/* 横向滚动容器 */ width: 0.28rem;
.scroll-box { height: 0.28rem;
}
/* 横向滚动容器 */
.scroll-box {
display: flex; display: flex;
gap: 10px; gap: 10px;
overflow-x: auto; overflow-x: auto;
scroll-behavior: smooth; scroll-behavior: smooth;
scrollbar-width: none; scrollbar-width: none;
} }
.scroll-box::-webkit-scrollbar { .scroll-box::-webkit-scrollbar {
display: none display: none
} }
.right-card { .right-card {
flex-shrink: 0; flex-shrink: 0;
background: #FAFAFA; background: #FAFAFA;
border-radius: 8px; border-radius: 8px;
@@ -144,27 +161,39 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding-top: 8px; padding-top: 8px;
} }
.card {
display: flex;
flex-direction: column;
align-items: center;
border-radius: 12px;
padding-left: 19px;
padding-right: 19px;
.card-img { }
.card-img {
width: 1.52rem; width: 1.52rem;
background: #f1f1f1; background: #f1f1f1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
color: #999; color: #999;
} margin-top: 8px;
}
.card-img img { .card-img img {
width: 100%; width: 100%;
}
.card-info { }
padding: 8px;
text-align: center
}
.card-name { .card-info {
text-align: center;
padding-top: 8px;
padding-bottom: 10px;
}
.card-name {
font-size: 0.2rem !important; font-size: 0.2rem !important;
width: 1.52rem; width: 1.52rem;
height: auto; height: auto;
@@ -174,22 +203,21 @@
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
overflow: hidden; overflow: hidden;
} }
.card-model { .card-model {
font-size: 0.16rem !important; font-size: 0.16rem !important;
color: #686A70; color: #686A70;
margin-top: 4px margin-top: 4px
} }
/* 内容区块默认隐藏 */ /* 内容区块默认隐藏 */
.tab-pane { .tab-pane {
display: none display: none
} }
/* 激活时显示 */ /* 激活时显示 */
.tab-pane.active { .tab-pane.active {
display: block; display: block;
} }