如何在 tailwind CSS 中将图标的位置从左移到右?
How to shift the position of an icon from left to right in tailwind CSS?
我自己是 tailwind 的初学者 CSS。因此,我对如何将此关闭图标的位置从左侧更改为右侧感到震惊。如果可能的话,请您也帮助我,因为我尝试了文档中的所有内容,但没有任何帮助。这是代码。我想要顺风 CSS.
中的答案
function Sidebar() {
return (
<div className="w-72 bg-white text-gray-100 shadow-lg">
<div className="p-7 text-sm">
<button className='text-slate-800 hover:text-white hover:bg-black rounded-full p-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer'>
<SwitchHorizontalIcon className ='h-5 w-5' />
</button>
<a className="flex items-center space-x-5 p-5 text-slate-800">
<MusicNoteIcon className="h-5 w-5" />
<p className="font-semibold hover:font-bold">
Sovereignty Kingdom
</p>
</a>
<nav className="flex items-center space-x-3 rounded-lg p-3 text-slate-800 hover:bg-black hover:text-white my-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer">
<HomeIcon className="h-5 w-5" />
<p>Home</p>
</nav>
<nav className="flex items-center space-x-3 rounded-lg p-3 text-slate-800 hover:bg-black hover:text-white my-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer">
<TrendingUpIcon className="h-5 w-5" />
<p>Trends</p>
</nav>
</div>
</div>
)
}
export default Sidebar```
如果您只是指 button
中的第一个图标,那么您需要执行以下操作
首先,给第二个 div
(button
的父级)这些 类 flex flex-col
,然后为按钮添加 self-end
以对齐它向右
<script src="https://cdn.tailwindcss.com"></script>
<div class="w-72 bg-white text-gray-100 shadow-lg">
<div class=" text-sm h-full flex flex-col ">
<button class='text-slate-800 self-end hover:text-white hover:bg-black rounded-full p-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer'>
<div class ='h-5 w-5 bg-red-500 rounded-full' />
</button>
<a class="flex items-center space-x-5 p-5 text-slate-800">
<MusicNoteIcon class="h-5 w-5" />
<p class="font-semibold hover:font-bold">
Sovereignty Kingdom
</p>
</a>
<nav class="flex items-center space-x-3 rounded-lg p-3 text-slate-800 hover:bg-black hover:text-white my-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer">
<HomeIcon class="h-5 w-5" />
<p>Home</p>
</nav>
<nav class="flex items-center space-x-3 rounded-lg p-3 text-slate-800 hover:bg-black hover:text-white transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer">
<TrendingUpIcon class="h-5 w-5" />
<p>Trends</p>
</nav>
</div>
</div>
我自己是 tailwind 的初学者 CSS。因此,我对如何将此关闭图标的位置从左侧更改为右侧感到震惊。如果可能的话,请您也帮助我,因为我尝试了文档中的所有内容,但没有任何帮助。这是代码。我想要顺风 CSS.
中的答案function Sidebar() {
return (
<div className="w-72 bg-white text-gray-100 shadow-lg">
<div className="p-7 text-sm">
<button className='text-slate-800 hover:text-white hover:bg-black rounded-full p-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer'>
<SwitchHorizontalIcon className ='h-5 w-5' />
</button>
<a className="flex items-center space-x-5 p-5 text-slate-800">
<MusicNoteIcon className="h-5 w-5" />
<p className="font-semibold hover:font-bold">
Sovereignty Kingdom
</p>
</a>
<nav className="flex items-center space-x-3 rounded-lg p-3 text-slate-800 hover:bg-black hover:text-white my-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer">
<HomeIcon className="h-5 w-5" />
<p>Home</p>
</nav>
<nav className="flex items-center space-x-3 rounded-lg p-3 text-slate-800 hover:bg-black hover:text-white my-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer">
<TrendingUpIcon className="h-5 w-5" />
<p>Trends</p>
</nav>
</div>
</div>
)
}
export default Sidebar```
如果您只是指 button
中的第一个图标,那么您需要执行以下操作
首先,给第二个 div
(button
的父级)这些 类 flex flex-col
,然后为按钮添加 self-end
以对齐它向右
<script src="https://cdn.tailwindcss.com"></script>
<div class="w-72 bg-white text-gray-100 shadow-lg">
<div class=" text-sm h-full flex flex-col ">
<button class='text-slate-800 self-end hover:text-white hover:bg-black rounded-full p-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer'>
<div class ='h-5 w-5 bg-red-500 rounded-full' />
</button>
<a class="flex items-center space-x-5 p-5 text-slate-800">
<MusicNoteIcon class="h-5 w-5" />
<p class="font-semibold hover:font-bold">
Sovereignty Kingdom
</p>
</a>
<nav class="flex items-center space-x-3 rounded-lg p-3 text-slate-800 hover:bg-black hover:text-white my-2 transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer">
<HomeIcon class="h-5 w-5" />
<p>Home</p>
</nav>
<nav class="flex items-center space-x-3 rounded-lg p-3 text-slate-800 hover:bg-black hover:text-white transition ease-in-out delay-50 hover:-translate-y-1 hover:scale-110 duration-200 cursor-pointer">
<TrendingUpIcon class="h-5 w-5" />
<p>Trends</p>
</nav>
</div>
</div>