[英]How can I put in my drawer echo with react-navigation lines in gray below the text?
[英]How can I align my text and put the button on the extrem right of my gray bar?
我怎樣才能在我的灰色欄中顯示我的 Invitee2 有點高? 對於我的按鈕,我怎樣才能將它放在灰色條的最右側?
<div className="bg-gray-200 p-5 h-5 pl-2 mb-2 text-md text-primary-500 font-bold text-gray-500">
Invitee {i + 1}
<span className="float-right -mt-5">
{!!i && (
<Button primary className="rounded-md float-right mt-4" onClick={() => removeInvitee(pId)}>
- Invitee
</Button>
)}
</span>
和Button.jsx
:
export default function Button({ onClick,primary,children,disabled }) {
return <button
onClick={onClick}
className={`${primary
? ' cursor-pointer rounded-md bg-primary-700 py-2 px-3 text-white hover:bg-blue-700 hover:text-white'
: 'bg-transparent text-gray border border-primary-500 hover:border-primary-100 hover:text-primary-100 transition duration-200 '}
text-primary-fg py-2 px-3 rounded-md transition-colors `}
disabled={disabled}
>{children}</button>
}
在div
類中添加flex flex-row justify-between items-center
並刪除float-right
旁邊的span
類中的-mt-5
檢查下面的代碼
<div className="flex flex-row justify-between items-center bg-gray-200 p-5 h-5 pl-2 mb-2 text-md text-primary-500 font-bold text-gray-500">
Invitee {i + 1}
<span className="float-right">
{!!i && (
<Button primary className="rounded-md float-right mt-4" onClick={() => removeInvitee(pId)}>
- Invitee
</Button>
)}
</span>
</div>
您可以使用 flexbox 屬性來制作您想要的設計。 我在下面創建了非常相似的示例,請在此處添加您的函數並將class
替換為className
。
<script src="https://cdn.tailwindcss.com"></script> <div class="container mx-auto py-4"> <div class="bg-gray-200 text-md flex items-center justify-between rounded-r-md"> <div class=" font-bold text-gray-500 ml-4" >Invitee 2</div> <div class=""> <Button primary class="rounded-md bg-black text-white py-2 px-4" onclick="removeInvitee(pId)"> - Invitee </Button> </div> </div> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.