【发布时间】:2018-01-24 14:51:06
【问题描述】:
有没有人有这个错误,输入组插件或下拉菜单占据了整个宽度的一半而不是 100%。 (基本上 InputGroupButton 占用了另外 50%,因此 100% 宽度自动在两个元素之间展开,但在 Reactstrp 文档中,所有迹象都表明这与预期行为背道而驰)
我希望我的输入组像其他组一样是 100% 宽度。 https://reactstrap.github.io/components/input-group/
这是我目前拥有的:
如果我打开检查元素:
您可以看到 InputGroupButton 没有设置填充或边距,例如“auto”或您希望对此负责的类似内容。
这是关于密码字段的反应渲染的小片段:
render() {
return (
<Label className="password">
<InputGroup>
<Input
className="password__input"
placeholder="Mot de Passe"
type={this.state.type}
onChange={this.passwordStrength}
/>
<InputGroupButton><Button onClick={this.showHide}>
{this.state.type === 'password' ?
<i className="fa fa-eye" aria-hidden="true" />
:
<i className="fa fa-eye-slash" aria-hidden="true" />
}</Button></InputGroupButton>
</InputGroup>
<span
className="password__strength"
data-score={this.state.score}
/>
</Label>
);
}
这是调用它的渲染(在“ShowPassword”中调用):
render() {
return (
<div>
<Button color="info" onClick={this.toggle}>{this.props.buttonLabel}</Button>
<Modal isOpen={this.state.modal} toggle={this.toggle} className={this.props.className}>
<ModalHeader toggle={this.toggle}>Créer un compte</ModalHeader>
<ModalBody>
Veuillez renseigner les champs ci-dessous afin de créer votre compte
<InputGroup>
<Input placeholder="Nom d'utilisateur" />
</InputGroup>
<InputGroup>
<Input placeholder="E-mail" />
</InputGroup>
<InputGroup>
<ShowPassword />
</InputGroup>
<InputGroup>
<Input placeholder="Confirmer"/>
</InputGroup>
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={this.toggle}>Envoyer</Button>{' '}
<Button color="secondary" onClick={this.toggle}>Annuler</Button>
</ModalFooter>
</Modal>
</div>
);
}
【问题讨论】:
-
拜托各位,我在网上找不到关于这个问题的任何信息。
-
现在有赏金了,请帮忙!
-
如果您可以在 jsFiddle 上反映这个问题,这将非常有助于回答
-
我不知道如何在jsfiddle中使用reacstrap。