[英]How to align material-ui icons to right?
I have a dynamically generated list which is generated by the following code我有一个由以下代码生成的动态生成的列表
<list className = "todos-list">
{allTodos.map((todo, index)=> {
return (
<li className = "todo-element"> {todo} <DeleteButton id= {index}
callBackFunction = {deleteItem}/> </li>)
}
)}
</list>
now as you can see {todo} and are placed next to each other so in the output also they are just placed next to each other as shown in the image attached (please do see it)现在您可以看到 {todo} 并彼此相邻放置,因此在 output 中,它们也只是彼此相邻放置,如附图所示(请查看)
the code to is shown below代码如下所示
<span className = "DeleteButton"><DeleteIcon onClick = {deleteMain}/></span>
Delete icon is taken from material-ui/icons
now I am having a problem in positioning the delete button to the right so that in all list items it is at a uniform distance from the boundary,(please see the image attached you will get the problem )删除图标现在取自material-ui/icons
我在将删除按钮定位到右侧时遇到问题,以便在所有列表项中它与边界的距离一致,(请参阅所附图像,您将获得问题 )
Please do let me know what can I do here??请让我知道我可以在这里做什么?
Try applying these styles:尝试应用这些 styles:
todo-element class:待办事项元素 class:
{
width: 100%
}
Delete button:删除按钮:
{
float: right
}
If you're using inline styles for button:如果您使用内联 styles 作为按钮:
<DeleteButton style={{ float: 'right' }} id={index} callBackFunction = {deleteItem}/>
#parent-element {
position:absolute;
}
.DeleteButton{
position:relative;
right:5;
}
This could work.这可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.