css - 在 react-bootstrap 中更改 NavDropdown 的颜色和背景颜色
问题描述
使用我NavDropdown
的 in react-bootstrap
,我无法设置其颜色或背景颜色的样式...
<NavDropdown eventKey={3} className="text-center" style={{ fontSize: `130%` }} title="Items to Choose" >
<LinkContainer to="/about">
<MenuItem eventKey={3.1} className="text-center">About</MenuItem>
</LinkContainer>
<MenuItem divider />
<LinkContainer to="/products">
<MenuItem eventKey={3.2} className="text-center">Products</MenuItem>
</LinkContainer>
<MenuItem divider />
<LinkContainer to="/blog-index">
<MenuItem eventKey={3.3} className="text-center">Blog</MenuItem>
</LinkContainer>
</NavDropdown>
我可以使用更改字体大小style={{ fontSize: '130%' }}
,但我也想使用更改颜色和背景颜色,..
style={{ fontSize: '130%', color: '#fff', backgroundColor: 'blue' }}
...但是color
并且backgroundColor
不在括号内工作。
我尝试做的一件事是将<NavDropdown>
元素包装在 style 中div
,但这会弄乱 Navbar 元素的对齐方式。
解决方案
也可以提供标题文本作为 JSX 元素。
<NavDropdown
title={
<span className="text-primary my-auto">Dropdown</span>
}
id="nav-dropdown"
>
<NavDropdown.Item>Action</NavDropdown.Item>
<NavDropdown.Item>Another action</NavDropdown.Item>
</NavDropdown>
并且不需要编写自定义 CSS,这可能是我们希望避免的事情。
推荐阅读
- postgresql - 如何使用不同的 PostgreSQL 实例进行生产测试
- ios - 使 UIViewController 成为 UITableViewCell 内的 UICollectionView 的代表
- node.js - 什么是 nodeJS 性能中的 I/O 缩放问题?
- python - 作为接收整数的因数的素数
- java - 静态 x 私有:价值可见性的成本
- java - 使实例变量保持其新值
- mysql - 如何在mysql中使用超过2个条件更新当前时间
- python - 将原始数据包转换为 pcap 格式并附加到 pcap 文件
- php - 尝试根据请求获取表单输出
- javascript - 如何使用样式标签内的 javascript 变量通过 document.write() 定位 div