用户提及组件
一个响应式用户提及组件,支持黑暗主题,使用 Tailwind CSS。不需要 JavaScript,仅需 HTML 和 Tailwind 类。对于暗模式,请使用 Tailwind 的 dark: 前缀进行样式设置。图片来自 picsum.photos,头像来自 randomuser.me。
HTML 代码
<div class="bg-gray-100 dark:bg-gray-900 py-8">
<div class="max-w-3xl mx-auto px-4">
<h2 class="text-2xl font-semibold text-gray-800 dark:text-white mb-4">User Mentions</h2>
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<div class="flex items-center mb-4">
<img src="https://randomuser.me/api/portraits/men/32.jpg" alt="User Avatar" class="w-10 h-10 rounded-full mr-4">
<div>
<p class="text-gray-800 dark:text-white font-semibold">John Doe</p>
<p class="text-gray-500 dark:text-gray-400 text-sm">@johndoe</p>
</div>
</div>
<p class="text-gray-700 dark:text-gray-300 leading-relaxed mb-4">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<div class="flex justify-end text-gray-500 dark:text-gray-400 text-sm">
<span>2 days ago</span>
</div>
</div>
<!-- Repeat similar blocks for other mentions -->
</div>
</div>