add backToTop button

This commit is contained in:
Steven Lynn
2024-08-06 17:46:59 +08:00
parent a1b7f80017
commit 348192f1b9
3 changed files with 69 additions and 2 deletions

View File

@@ -123,3 +123,33 @@
display: block;
}
}
#back-to-top {
position: fixed;
bottom: 20px;
right: 20px;
background-color: #dfd3c3;
color: #333;
width: 50px;
height: 50px;
border-radius: 50%;
border: none;
cursor: pointer;
display: none; /* 初始状态隐藏 */
align-items: center;
justify-content: center;
font-size: 24px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
z-index: 1000;
transition: all 0.3s ease; /* 添加过渡效果 */
}
#back-to-top:hover {
background-color: #d0c3b4; /* 稍微深一点的颜色作为悬停效果 */
transform: translateY(-3px); /* 悬停时稍微上移 */
}
#back-to-top:active {
transform: translateY(1px); /* 点击时下移,创造按压效果 */
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2); /* 减小阴影 */
}