React-Bootstrap-NavItem上没有圆角

时间:2018-06-26 12:03:10

标签: javascript css reactjs twitter-bootstrap-3 react-bootstrap

我希望具有与pills样式相同的外观,但没有圆角

这是我到目前为止所拥有的

<style type="text/css">{`
.nav-pills > li + li {
    border-radius: 0 !important;
}
`}</style>
<Nav
     bsStyle="pills"
     justified
     activeKey={this.props.currentStep}
     onSelect={this.updateCurrentStep.bind(this)}
>
    <NavItem eventKey={1} title="Template">Template</NavItem>
    <NavItem eventKey={2} title="Edit">Edit</NavItem>
    <NavItem eventKey={3} title="Preview">Preview</NavItem>
</Nav>

如何将border-radius中的NavItem设置为0?它确实出现在li项目的规则中,但它没有任何改变。

2 个答案:

答案 0 :(得分:0)

React中有许多不同的(可能更好)的样式处理方式,但是要使用类似的样式块,您需要添加dangerouslySetInnerHTML={{__html:

<style dangerouslySetInnerHTML={{__html: `
    .nav-pills > li + li { border-radius: 0 !important; }
`}} />

答案 1 :(得分:0)

在样式文件中,您可以提供:

.nav-pills>li>a {
    border-radius: 0 !important;
}

应将边框半径的样式重置为0。

const Nav = ReactBootstrap.Nav;
const NavItem = ReactBootstrap.NavItem;

class App extends React.Component {
  render() {
    return (
      <Nav
          bsStyle="pills"
          justified
          activeKey={this.props.currentStep}
          onSelect={this.updateCurrentStep}
      >
          <NavItem eventKey={1} title="Template">Template</NavItem>
          <NavItem eventKey={2} title="Edit">Edit</NavItem>
          <NavItem eventKey={3} title="Preview">Preview</NavItem>
      </Nav>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('app'));
.nav-pills>li>a {
    border-radius: 0 !important;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap/0.32.1/react-bootstrap.js"></script>

<div id="app"></div>