简体   繁体   English

React-Bootstrap-NavItem上没有圆角

[英]No rounded corners on React-Bootstrap-NavItem

I want to have the same look as the pills style but without the rounded corners 我想拥有与pills样式相同的外观,但没有圆角

this is what i have so far 这就是我到目前为止

<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>

How do I set the border-radius of my NavItem to 0? 如何将NavItemborder-radius设置为0? It does appear in the rules of the li item but it does not change anything. 它确实出现在li项的规则中,但它没有任何改变。

There are many different (and arguably better) ways to handle styling in React, but to use a style block like that you need to add dangerouslySetInnerHTML={{__html: 在React中有很多不同的(可能是更好的)样式处理方式,但是要使用类似的样式块,您需要dangerouslySetInnerHTML={{__html:地添加dangerouslySetInnerHTML={{__html:

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

Inside your styling file, you can give: 在样式文件中,您可以提供:

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

which should reset the styles of border radius to 0. 应该将边框半径的样式重置为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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM