Files
BroadcastChannel/src/assets/global.css
ccbikai 7d98d481cc 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.
2024-08-08 21:41:36 +08:00

142 lines
2.2 KiB
CSS

* {
-webkit-tap-highlight-color: transparent;
}
html {
scroll-behavior: smooth;
}
.site-title {
view-transition-name: site-title;
transition: 0.2s ease;
}
.item {
transition: 0.2s ease;
}
.search-icon {
position: absolute;
top: 20px;
right: 0px;
width: 24px;
height: 24px;
padding: 4px;
appearance: none;
outline: none;
&:after {
content: '🔍';
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-color: var(--background-color);
text-align: center;
vertical-align: middle;
line-height: 24px;
}
}
.search-icon:checked + .search-form {
display: block !important;
}
.search-form {
display: none;
background: rgba(255, 255, 255, 0.75);
padding: 8px;
position: sticky;
top: 60px;
border-radius: var(--box-border-radius);
> input {
border: 1px solid var(--background-color);
border-radius: var(--box-border-radius);
outline: none;
font-size: 12px;
line-height: 2.4;
padding: 0 0.5em;
box-sizing: border-box;
width: 100%;
}
}
.copyright-wrap {
position: sticky;
top: 120px;
color: #666;
line-height: 1.5;
font-size: 14px;
display: none;
}
@media screen and (min-width: 600px) {
.search-form {
display: block;
}
.search-icon {
display: none;
}
.copyright-wrap {
display: block;
}
}
#back-to-top {
display: none;
position: fixed;
bottom: 20px;
right: 20px;
background-color: #fff;
color: var(--secondary-color);
width: 32px;
height: 32px;
border-radius: 100%;
border: none;
font-size: 24px;
text-decoration: none;
opacity: 0;
transition:
opacity 0.3s,
transform 0.3s;
z-index: 1000;
&:hover {
transform: translateY(-3px);
}
&: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 {
display: flex;
align-items: center;
justify-content: center;
animation: fadeIn 0.5s linear both;
animation-timeline: view(block 0 100vh);
}
@keyframes fadeIn {
from {
opacity: 0;
pointer-events: none;
}
to {
opacity: 0.9;
pointer-events: auto;
}
}
}