mirror of
https://github.com/d0zingcat/BroadcastChannel.git
synced 2026-06-04 07:26:51 +00:00
feat: enhance scroll behavior and back-to-top button
Improved scrolling smoothness and updated back-to-top button styling for better user experience. Simplified button visibility control using modern CSS techniques, ensuring compatibility and responsiveness across browsers.
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
}
|
||||||
|
|
||||||
.site-title {
|
.site-title {
|
||||||
view-transition-name: site-title;
|
view-transition-name: site-title;
|
||||||
transition: 0.2s ease;
|
transition: 0.2s ease;
|
||||||
@@ -83,68 +87,55 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#back-to-top {
|
#back-to-top {
|
||||||
|
display: none;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 20px;
|
bottom: 20px;
|
||||||
right: 20px;
|
right: 20px;
|
||||||
background-color: #dfd3c3;
|
background-color: #fff;
|
||||||
color: #333;
|
color: var(--secondary-color);
|
||||||
width: 50px;
|
width: 32px;
|
||||||
height: 50px;
|
height: 32px;
|
||||||
border-radius: 50%;
|
border-radius: 100%;
|
||||||
border: none;
|
border: none;
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition:
|
transition:
|
||||||
opacity 0.3s,
|
opacity 0.3s,
|
||||||
transform 0.3s;
|
transform 0.3s;
|
||||||
cursor: pointer;
|
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
}
|
|
||||||
|
|
||||||
/* 使用 @scroll-timeline 控制按钮的显示 */
|
&:hover {
|
||||||
@supports (animation-timeline: scroll()) {
|
transform: translateY(-3px);
|
||||||
@scroll-timeline buttonVisibility {
|
|
||||||
source: auto;
|
|
||||||
orientation: vertical;
|
|
||||||
scroll-offsets: 0%, 100px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
transform: translateY(1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
filter: var(--icon-secondary-filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use @scroll-timeline to control the display of the button */
|
||||||
|
@supports (animation-timeline: view()) {
|
||||||
#back-to-top {
|
#back-to-top {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
animation: fadeIn 0.5s linear both;
|
animation: fadeIn 0.5s linear both;
|
||||||
animation-timeline: buttonVisibility;
|
animation-timeline: view(block 0 100vh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fadeIn {
|
@keyframes fadeIn {
|
||||||
from {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
to {
|
to {
|
||||||
opacity: 1;
|
opacity: 0.9;
|
||||||
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#back-to-top:hover {
|
|
||||||
background-color: #b0a295;
|
|
||||||
transform: translateY(-3px);
|
|
||||||
}
|
|
||||||
|
|
||||||
#back-to-top:active {
|
|
||||||
transform: translateY(1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 为不支持 @scroll-timeline 的浏览器提供的回退样式 */
|
|
||||||
@supports not (animation-timeline: scroll()) {
|
|
||||||
#back-to-top {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* CSS Scroll Behavior 实现返回顶部的平滑滚动 */
|
|
||||||
html {
|
|
||||||
scroll-behavior: smooth;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user