gpt4 book ai didi

reactjs - React 中的内联样式 CSS 不起作用

转载 作者:行者123 更新时间:2023-12-03 13:50:56 31 4
gpt4 key购买 nike

我不知道为什么我的内联 CSS 在这里不起作用。您可以在<div className="navbar-nav" style={background-color: red}>上看到它。任何帮助将不胜感激。提前致谢。

完整代码

import React from 'react';
import {
BrowserRouter,
Route,
Link
} from 'react-router-dom';

const HeaderWrapper = () => (
<div>
<nav className="navbar navbar-expand-lg navbar-dark bg-dark">
<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<div className="collapse navbar-collapse" id="navbarNavAltMarkup">
<div className="navbar-nav" style={background-color: red}>
<Link className="nav-item nav-link active" to="/">Home <span className="sr-only">(current)</span></Link>
<Link className="nav-item nav-link" to="/about">About Us</Link>
<Link className="nav-item nav-link" to="/">Whats New</Link>
<Link className="nav-item nav-link" to="/">Designers</Link>
<Link className="nav-item nav-link" to="/">Clothing</Link>
<Link className="nav-item nav-link" to="/">Accessories</Link>
<Link className="nav-item nav-link" to="/">How it Works</Link>
<Link className="nav-item nav-link" to="/">Magazine</Link>
</div>
</div>
</nav>
</div>
)

export default HeaderWrapper

最佳答案

尝试:

<div className="navbar-nav" style={{ backgroundColor: 'red' }}>

关于reactjs - React 中的内联样式 CSS 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46087571/

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