【问题标题】:<div> not using full bootstrap column space<div> 没有使用完整的引导列空间
【发布时间】:2018-09-28 18:44:12
【问题描述】:

我试图让三个按钮使用一列的全宽。

按钮的网格为 3,其他组件的网格为 9。

这是visual。所以基本上按钮也应该占据用红色标记的空间,它们应该只使用整个 3 列。

这是我导入组件的 App.js:

<div className="container-full padding-0" style={{overflow:'hidden', overflowY:'hidden'}}>
    <div className="row">
        <div className="col-sm-3" style={{borderRight:"1px solid #000"}}>
            <div className="row no-gutters mt-auto">
                <div className="col-sm-3">
                    <COMPONENT1/>
                </div>
                <div className="col-sm-9">
                    <COMPONENT2/>
                </div>
            </div>
            <COMPONENT3 store={store} style={{overflow:'hidden'}}/>
            <COMPONENT4/>
            <BUTTONS/> --------------------------> Here are the buttons
       </div>
       <div className="col-sm-9" style={{paddingRight: 0, paddingLeft: 0}}>
            <COMPONENT6 = {store} style={{overflow:'hidden'}}/>
            <br/>
            <COMPONENT7/>
            <COMPONENT8 store={store} clicked={this.clicked}/>
       </div>
    </div>
</div>

和按钮组件:

<div className="row no-gutters mt-auto" style={{paddingTop:10}}>
    <div className="col-sm-4">
        <Button variant="raised" style={buttonStyle}>A</Button>
    </div>

    <div className="col-sm-4">
        <Button variant="raised" style={buttonStyle}>B</Button>   
    </div>

    <div className="col-sm-4">
        <Button variant="raised" style={buttonStyle}>C</Button>
    </div>
</div>

以及按钮的 css:

const buttonStyle = {
    fontSize: 20,
    textAlign: 'center',
    display:'inline-block',
    width:'100%',
    height:100
}

编辑:这是用户界面的快速pic

【问题讨论】:

  • 你能提供一个 JSFiddle 或 URL 吗?
  • 当然,here 是。虽然它看起来不像是在阅读引导程序classNames

标签: html css reactjs bootstrap-4 material-ui


【解决方案1】:

你能不能试试下面的方法:

row no-gutters mt-auto下面的css规则:

style={{ display: 'flex', flex: 1, flexDirection: 'row' }}

它肯定会起作用!

谢谢

【讨论】:

  • 你确定吗?因为我在代码框(codesandbox.io/s/92j3kv49wy)中检查了它,它在这里工作......
  • 我将style={{paddingTop:10, display:'flex', justifyContent: 'space-between'}} 添加到row no-gutters mt-auto divflex: 0 0 33.33% 到所有&lt;div className="col-sm-4" style={{height:100, flex: '0 0 33.33%'}}&gt; divs,但它没有改变任何东西。
  • 好的,你能试试用这个style={{flex: 1, flexDirection: 'row'}}替换我的css代码吗? .. 将此添加到行 no-gutters mt-auto
  • 所有&lt;div&gt;s ?
  • No .. 在这个 div row no-gutters mt-auto
猜你喜欢
  • 1970-01-01
  • 2019-11-19
  • 2021-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多