[英]Position of popover in overlaytrigger using react-bootstrap
Bootstrap for my project. 我的项目的Bootstrap。 My JavaScript code is following:
我的JavaScript代码如下:
<OverlayTrigger trigger="click" placement="right" overlay={<Popover ><strong>Gender: </strong>Please select your gender</Popover>}>
<input className="col-sm-1 col-xs-1" type="radio" name="gender" value="Male" checked={this.state.gender ==="Male"} onChange={this.onRequiredGender} disabled={this.state.maleDisable} />
</OverlayTrigger>
on click radio button is providing me Popover but position of that Popover is just next to that radio button. 点击单选按钮为我提供了Popover,但Popover的位置就在那个单选按钮的旁边。
I tried by CSS: 我试过CSS:
.popover .right{
left: 400px
}
even using React-bootstrap positionLeft={400}
甚至使用React-bootstrap
positionLeft={400}
that was something like following: 这就是以下内容:
<OverlayTrigger trigger="click" placement="right" overlay={<Popover positionLeft={400} ><strong>Gender: </strong>Please select your gender</Popover>}>
<input className="col-sm-1 col-xs-1" type="radio" name="gender" value="Male" checked={this.state.gender ==="Male"} onChange={this.onRequiredGender} disabled={this.state.maleDisable} />
</OverlayTrigger>
still position of popover is same as the position of radio button. 弹出窗口的静止位置与单选按钮的位置相同。
If anyone can help me to shift my Popover given position then It will be great. 如果有人能帮助我改变我的Popover位置那么它会很棒。
Thanks in advance.. 提前致谢..
The thing is positionLeft
prop that you are trying to use is overridden by the OverlayTrigger
and you should'nt use it. 你试图使用的
positionLeft
prop被OverlayTrigger
覆盖,你不应该使用它。 However if you want a finer control over the Popover
element I suggest you create your own popover component
that does something with the positionLeft
and positionTop
component that are passed in to it by the Overlay component
. 但是,如果您想要更好地控制
Popover
元素,我建议您创建自己的popover component
,该组件使用由Overlay component
传递给它的positionLeft
和positionTop
Overlay component
。
class CustomPopover extends React.Component {
render(){
return (
<ReactBootstrap.Popover {...this.props} positionLeft={400}>
{ this.props.children }
</ReactBootstrap.Popover>
)
}
}
You can use it like 你可以像使用它一样
<Overlay>
<CustomPopover><strong>Gender: </strong>Please select your gender</CustomPopover>
</Overlay>
Here is an issue on github: https://github.com/react-bootstrap/react-bootstrap/issues/816 . 这是github上的一个问题: https : //github.com/react-bootstrap/react-bootstrap/issues/816 。 Check it out.
看看这个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.