理想情况下,当页面宽度缩小时,“添加联系人”按钮和“创建广告系列”会尽可能长时间保持在同一行。相反,当页面缩小时,“创建活动”按钮会立即切换到下一行:
我认为这是我设置Bootstrap行的一个问题。请在此处找到我的React和HTML:http://jsfiddle.net/connorcmu/Lq2ew48v/
相关部分:
<section className="row">
<div className="col-lg-3">
<Dropdown
secondary={this.toggle('showCreateDropdown')}
caption={this.getIntlMessage('addContact')}
primary={this.toggleForm('contactForm', 'uploadForm')}
show={this.state.showCreateDropdown}
fields={[{
value: this.getIntlMessage('uploadMultiple'),
action: this.toggleForm('uploadForm', 'contactForm')
}]} />
</div>
<div className="col-lg-3">
<a target="_blank"
data-track="click"
id="createNewsletter"
data-action="navigate"
href={props.gemUrl}
className="btn btn-default newsletter"
onClick={this.onCreateNewsletter}
data-label="create-newsletter">
{self.getIntlMessage('createCampaign')}
</a>
</div>
答案 0 :(得分:0)
它应该是class =&#34; ...&#34;而不是className =&#34; ...&#34;
您可以在一个div中添加几个col类,以定义每个定义的屏幕大小的div的个别行为。而不是class =&#34; col-lg-3&#34;你可以使用class =&#34; col-xs-12 col-md-6 col-lg-3&#34;。
答案 1 :(得分:0)
这是基本的Bootstrap,我建议您阅读文档以获得更好的想法。
在这里,你使用col-lg-3
告诉divs在屏幕宽度很大时保持彼此相邻。但是,您没有提到当屏幕宽度为中(md),小(sm)或超小(xs)时div应如何表现。因此,当屏幕宽度减小时,它们都会级联,每行占用一行,与col-*-12
相同。因此,解决方案是定义所有或所需屏幕尺寸的行为。所以,你的代码应该是: -
<div className="col-lg-3 col-md-6 col-sm-12">
<Dropdown
secondary={this.toggle('showCreateDropdown')}
caption={this.getIntlMessage('addContact')}
primary={this.toggleForm('contactForm', 'uploadForm')}
show={this.state.showCreateDropdown}
fields={[{
value: this.getIntlMessage('uploadMultiple'),
action: this.toggleForm('uploadForm', 'contactForm')
}]} />
</div>
<div className="col-lg-3 col-md-6 col-sm-12">
<a target="_blank"
data-track="click"
id="createNewsletter"
data-action="navigate"
href={props.gemUrl}
className="btn btn-default newsletter"
onClick={this.onCreateNewsletter}
data-label="create-newsletter">
{self.getIntlMessage('createCampaign')}
</a>
</div>
答案 2 :(得分:0)
尝试使用此解决方案。之前所说的那种,但是为col-xs大小设置媒体断点以及col-sm和col-md:
render: function render() {
var self = this,
props = self.props;
return (
<div className="controls col-lg-12">
{this.renderInfo()}
{this.renderModal()}
<section className="row">
<div className="col-xs-4 col-sm-3 col-md-3 col-lg-3">
<Dropdown
secondary={this.toggle('showCreateDropdown')}
caption={this.getIntlMessage('addContact')}
primary={this.toggleForm('contactForm', 'uploadForm')}
show={this.state.showCreateDropdown}
fields={[{
value: this.getIntlMessage('uploadMultiple'),
action: this.toggleForm('uploadForm', 'contactForm')
}]} />
</div>
<div className="col-xs-4 col-sm-3 col-md-3 col-lg-3">
<a target="_blank"
data-track="click"
id="createNewsletter"
data-action="navigate"
href={props.gemUrl}
className="btn btn-default newsletter"
onClick={this.onCreateNewsletter}
data-label="create-newsletter">
{self.getIntlMessage('createCampaign')}
</a>
</div>
<div className="col-xs-4 col-sm-3 col-md-3 col-lg-3">
<span className="count">
{self.getIntlMessage('totalCount')}: {props.count}
</span>
</div>
<form className="col-xs-12 col-md-3 col-lg-3" onSubmit={self.search}>
<input
id="searchBar"
type="text"
ref="filterTextInput"
placeholder={self.getIntlMessage('search')}
value={self.state.query}
className={'form-control' + (self.state.searching ? ' searching' : '')}
onChange={self.search} />
</form>
</section>
{self.renderForm()}
</div>
);