css - 如何在引导程序中给按钮一个按钮右对齐?
问题描述
我正在尝试对齐一行右上角的两个按钮,但无论我使用什么方法,每次都会显示相同的结果,这是供您参考的代码:
import React from "react";
import bootstrap from "bootstrap";
import Container from "react-bootstrap/Container";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
const AdminPanel = () => {
const users = [{ name: "Talha" }, { name: "Ali" }];
return (
<Container className="pt-5">
<Row className="d-flex" style={{ height: "70vh" }}>
<Col className="shadow-lg bg-white rounded mx-5">
{users.map((user) => (
<Row
className="shadow my-3 mx-2 py-2 px-2 rounded font-weight-bold"
style={{ height: "7vh" }}
>
{user.name}
<div className="btn-group">
<a href="#">
<button className="btn btn-primary">Edit</button>
</a>
<a href="#">
<button className="btn btn-danger">Delete</button>
</a>
</div>
</Row>
))}
</Col>
<Col className="shadow-lg bg-white rounded mx-5">
<h1>
list
</h1>
</Col>
</Row>
</Container>
);
};
export default AdminPanel;
任何帮助,将不胜感激!!!!!
解决方案
将类:ml-auto
(= margin-left:auto !important
) 添加到:
<div className="btn-group ml-auto">
由于此 div 位于div.row
已display:flex;
应用属性的 div 中,因此它应自动将其推到右侧
推荐阅读
- c++ - 模板参数包扩展为单参数模板
- hibernate - JPA @ManyToMany 与 JoinTable 重复条目问题
- typescript - 如何从映射类型变为可区分的联合
- mesos - 当通过马拉松部署 pod 时,mesos master 停用代理
- python - 将预定义的数字分配给数据框中列行的值
- html - CSS 改变列之间内容的顺序
- c# - 依赖解析器的 Automapper IMapper 问题
- vb.net - 从另一个类调用 new() 函数
- sql - 添加一列以填充每个组的排名
- powershell - 如何从 Powershell/Powershell Core 中同一脚本内的另一个函数调用函数?