组件 粘滞导航 粘性导航组件

粘性导航组件

一个使用Tailwind CSS样式设计的响应式粘性导航组件,遵循材料设计原则,具有深色主题,包括随机占位图和头像。

预览

HTML 代码

<nav class="bg-white dark:bg-gray-800 shadow-lg fixed w-full z-10">
    <div class="max-w-7xl mx-auto p-4 flex justify-between items-center">
        <div class="flex items-center space-x-4">
            <img src="https://randomuser.me/api/portraits/men/1.jpg" alt="User Avatar" class="rounded-full w-10 h-10">
            <h1 class="text-xl font-bold text-gray-800 dark:text-white">My Website</h1>
        </div>
        <div>
            <ul class="flex space-x-4">
                <li><a href="#" class="text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition">Home</a></li>
                <li><a href="#" class="text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition">About</a></li>
                <li><a href="#" class="text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition">Services</a></li>
                <li><a href="#" class="text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition">Contact</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="pt-16">
    <header class="bg-gray-100 dark:bg-gray-900 h-screen flex items-center justify-center">
        <h2 class="text-3xl font-bold text-gray-800 dark:text-white">Welcome to My Website</h2>
    </header>
    <section class="p-8">
        <h3 class="text-2xl font-bold text-gray-800 dark:text-white mb-4">Gallery</h3>
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
            <img src="https://picsum.photos/200/300?random=1" alt="Random Image" class="rounded shadow-lg">
            <img src="https://picsum.photos/200/300?random=2" alt="Random Image" class="rounded shadow-lg">
            <img src="https://picsum.photos/200/300?random=3" alt="Random Image" class="rounded shadow-lg">
            <img src="https://picsum.photos/200/300?random=4" alt="Random Image" class="rounded shadow-lg">
        </div>
    </section>
</div>

<style>
    /* Dark mode styles */
    @media (prefers-color-scheme: dark) {
        body {
            background-color: #1f2937;
        }
    }
</style>

相关组件

粘性导航组件 - 黑暗模式粉彩

一个为深色模式设计的粘性导航栏,具有响应式布局和柔和的色彩点缀。导航栏在用户滚动时保持在视口顶部,提高内容丰富页面的可用性。它包括一个用于徽标或站点标题和导航链接的占位符,用Tailwind CSS进行样式处理,呈现现代、干净的外观。

打开

粗野主义固定导航

一个具有响应式行为和深色模式支持的野兽派风格粘性导航组件,使用 Tailwind CSS。特点是高对比度、粗体排版和鲜明、原始的美学。

打开

灰度拟物化粘性导航

用于博客的响应式粘性导航栏,使用灰度调色板以拟物化样式。具有深色模式支持和简单的布局。使用 Tailwind CSS(仅限 HTML)构建,无需 JavaScript。拟物化设计旨在使导航栏看起来像一个物理的、略微凸起的元素。

打开