gpt4 book ai didi

html - React - 如何将字形图标对齐到最右边?

转载 作者:太空宇宙 更新时间:2023-11-04 01:14:25 26 4
gpt4 key购买 nike

我的 React 应用程序具有自动完成功能,在自动完成功能中我提供了列表和字形图标,然后如果我单击字形图标,内容将被插入到 MongoDB 中。

无论如何,我尝试将字形图标对齐到最右边,但我做不到。如果我将它移到 li 之外,语法就会出错。

以下是截图。 enter image description here

字形对文本是封闭的,但它应该在最右边。

我的代码如下:

<li key={_id}>{itemname}
<i className="glyphicon glyphicon-edit" onClick={() =>
this.addToReceiving(
itemid,
barcode,
itemname,
category,
stocktype,
itemtype,
wholesaleprice,
retailprice,
quantitystock,
receivingquantity,
description,
comment)}>
</i>
</li>

最佳答案

您可以使用 flexbox 来对齐元素。

给文本添加一个span

<li key={_id}>
<span>{itemname}</span>
<i className="glyphicon glyphicon-edit" onClick={() =>
this.addToReceiving(
itemid,
barcode,
itemname,
category,
stocktype,
itemtype,
wholesaleprice,
retailprice,
quantitystock,
receivingquantity,
description,
comment)}>
</i>
</li>

试试这个:-

li {
display: flex;
//This will push both child elements to far corner
//You can also try justify-content: space-around; if you want some space in the corner
justify-content: space-between;
}

关于html - React - 如何将字形图标对齐到最右边?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50520578/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com