Back to Top Button 组件
一个响应式、视觉上吸引人的“返回顶部”按钮,具有三重配色方案、渐变和平滑过渡,适用于作品集网站,包括深色模式支持。
HTML 代码
<div class="fixed bottom-6 right-6 z-50">
<!-- The button is initially hidden and would be revealed by JS on scroll -->
<!-- For demonstration, it's always visible here. In a real app, add a 'hidden' class by default -->
<button aria-label="Scroll to top" class="group flex h-14 w-14 items-center justify-center rounded-full shadow-lg transition-all duration-300 ease-in-out hover:scale-110 focus:outline-none focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800
bg-gradient-to-br from-emerald-400 via-teal-500 to-blue-600
dark:from-emerald-600 dark:via-teal-700 dark:to-blue-800">
<svg class="h-8 w-8 text-white transition-transform duration-300 ease-in-out group-hover:-translate-y-1" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 10l7-7m0 0l7 7m-7-7v18"></path>
</svg>
</button>
</div>