【问题标题】:Cant use CSS and justify content on react Bootstrap无法使用 CSS 并在反应 Bootstrap 上证明内容合理
【发布时间】:2021-09-19 00:07:40
【问题描述】:

所以我正在尝试使用 react bootstrap 创建我的应用程序,我想将背景颜色更改为我想要的 + 我想将链接标签移动到右侧,我相信在普通 HTML 中我们可以通过键入来实现它class="justify-content-end" 但我找不到方法。谁能帮帮我?之前谢谢。

这是我的代码:

import "../styles/Header.css"
import { Navbar, Nav} from "react-bootstrap"

function header() {
    return (
        <div>
            <Navbar bsClass="custom-navbar" expand="lg">
                <Navbar.Brand href="#home">React-Bootstrap</Navbar.Brand>
                <Navbar.Toggle aria-controls="basic-navbar-nav" />
                <Navbar.Collapse id="basic-navbar-nav">
                    <Nav className="justify-content-end">
                        <Nav.Link href="#facilities">Facilities</Nav.Link>
                        <Nav.Link href="#room">Room</Nav.Link>
                    </Nav>
                </Navbar.Collapse>
            </Navbar>
        </div>
    )
}

我的 Header.css:

.custom-navbar{
    background-color: #10255A;
}

【问题讨论】:

  • 这是拼写错误还是您缺少&lt;Nav&gt; 的结束标签?
  • 哦,我没有正确复制代码,我的代码中有一个结束标签

标签: css reactjs react-bootstrap


【解决方案1】:

目前,&lt;Nav&gt; 的 flex 方向是列,这意味着您必须使用 align-items-end 将链接标签向右移动

<Nav className="justify-content-end align-items-end">        

Codesandbox

【讨论】:

    猜你喜欢
    • 2020-05-03
    • 1970-01-01
    • 2020-05-27
    • 1970-01-01
    • 1970-01-01
    • 2021-05-01
    • 2014-04-08
    • 2016-03-28
    • 2020-05-08
    相关资源
    最近更新 更多