[英]How do I style the icon-bar of react-bootstrap's Navbar component?
I want to style the icon-bar
of a react-bootstrap's Navbar
component to have a background-color: white;
我想将react-bootstrap的Navbar
组件的icon-bar
为background-color: white;
. 。 However, my webpack scss loader does not allow me to style CSS classes with dashes, I can only use camel case. 但是,我的webpack scss加载器不允许我用破折号样式化CSS类,我只能使用驼峰式大小写。 This is my webpack config: 这是我的webpack配置:
{ test: /\.scss$/, loader: 'style!css?modules&importLoaders=2&sourceMap&localIdentName=[local]___[hash:base64:5]!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap' },
I prefer not to change this config. 我宁愿不更改此配置。 Instead I would like to change my JSX so I can attach a custom class to the icon-bar
element. 相反,我想更改JSX,以便可以将自定义类附加到icon-bar
元素。 How do I do this? 我该怎么做呢?
Home.scss Home.scss
.navbar {
.icon-bar {}
}
Home.js Home.js
<Navbar fixedTop fluid className={styles.navbar}>
<Navbar.Header>
...
</Navbar.Header>
<Navbar.Collapse eventKey={0}>
<Nav navbar className="navbar-right">
<LinkContainer to="/how-it-works">
<NavItem eventKey={2} className={styles.navItem}>How It Works</NavItem>
</LinkContainer>
</Nav>
</Navbar.Collapse>
</Navbar>
a simple solution is put the navbar in wrapper element, like this : 一个简单的解决方案是将导航栏放在包装器元素中,如下所示:
<div className={styles.navbar}>
<Navbar fixedTop fluid>
<Navbar.Header>
...
</Navbar.Header>
<Navbar.Collapse eventKey={0}>
<Nav navbar className="navbar-right">
<LinkContainer to="/how-it-works">
<NavItem eventKey={2} className={styles.navItem}>How It Works</NavItem>
</LinkContainer>
</Nav>
</Navbar.Collapse>
</Navbar>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.