组件 Back to Top 按钮 返回顶部按钮组件

返回顶部按钮组件

一个简单的返回顶部按钮,采用粗野风格设计,使用 Tailwind CSS,适合投资组合网站。它具有灰度配色方案和暗模式支持。

预览

HTML 代码

<div class="fixed bottom-5 right-5 z-50">
    <a href="#top" class="flex items-center justify-center w-12 h-12 rounded-full bg-gray-800 text-white hover:bg-gray-600 dark:bg-gray-900 dark:text-gray-300 dark:hover:bg-gray-700 transition-all duration-300 shadow-lg">
        ⬆️
    </a>
</div>

<div class="h-screen bg-gray-100 dark:bg-gray-800" id="top">
    <div class="container mx-auto p-5">
        <h1 class="text-3xl font-bold text-gray-900 dark:text-white">Portfolio</h1>
        <p class="text-gray-700 dark:text-gray-300">Showcasing my work and products.</p>
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5 mt-5">
            <div class="bg-white dark:bg-gray-700 p-5 shadow rounded-lg">
                <img src="https://picsum.photos/200" alt="Portfolio item" class="w-full rounded-lg">
                <h2 class="text-xl font-semibold text-gray-900 dark:text-white mt-2">Project Title</h2>
                <p class="text-gray-600 dark:text-gray-300">Description of the project goes here.</p>
            </div>
            <div class="bg-white dark:bg-gray-700 p-5 shadow rounded-lg">
                <img src="https://picsum.photos/201" alt="Portfolio item" class="w-full rounded-lg">
                <h2 class="text-xl font-semibold text-gray-900 dark:text-white mt-2">Project Title</h2>
                <p class="text-gray-600 dark:text-gray-300">Description of the project goes here.</p>
            </div>
            <div class="bg-white dark:bg-gray-700 p-5 shadow rounded-lg">
                <img src="https://picsum.photos/202" alt="Portfolio item" class="w-full rounded-lg">
                <h2 class="text-xl font-semibold text-gray-900 dark:text-white mt-2">Project Title</h2>
                <p class="text-gray-600 dark:text-gray-300">Description of the project goes here.</p>
            </div>
        </div>
    </div>
</div>

相关组件

Back to Top Button 组件

响应式返回顶部按钮组件,采用 Glassmorphism 设计、大地色调配色方案和复杂的交互,适用于仪表板。

打开

回到顶部按钮

一个极简的“返回顶部”按钮,使用 Tailwind CSS 设计,具备响应效果和暗黑主题支持。

打开

回到顶部按钮

一个最小且响应迅速的“Back to Top”按钮组件,支持深色模式。它在向下滚动后显示,并使用平滑滚动在单击时将用户返回到页面顶部。没有 JavaScript 用于滚动,只有 CSS。

打开