MuiThemeProvider中的React.Js布局

时间:2018-10-19 13:22:29

标签: reactjs material-ui

我正在尝试在MuiThemeProvider-标签中对齐项目。

这是我的代码:

    <MuiThemeProvider>
            <div style={{display: 'inline'}}>
               <Card onClick={this.handleOpen} className="Item" style={{backgroundImage: 'url(' + this.props.backdrop + ')', width: '15%', height: 175}}>
               </Card>

                <div style={{display: 'inline-flex'}}>
                    {this.props.title}
                </div>

            </div>

      </MuiThemeProvider>

这里是父文件:

         <div className="TitleList" data-loaded={this.state.mounted}>
            <div className="Title">
                <h1>{this.props.title}</h1>
                <div className="titles-wrapper">
                      <div className="title-row">
                    {titles}
                    </div>
                </div>
            </div>
        </div>

在这里您可以看到结果:

enter image description here

我希望图片以10px的边距彼此对齐(当我移除{this.props.title}时,效果很好)。

标题应在图片下方而不是右侧显示。

我尝试了CSS文件中的所有内容,但没有任何效果。

这是我的一些CSS:

       .TitleList {
         padding: 20px 40px ;
         box-sizing: border-box;
         -webkit-transition: opacity 3s ease;
         transition: opacity 3s ease;
         opacity: 0;
         position: relative;
         z-index: 0;
         display: flex;

         }
         ::-webkit-scrollbar {
         display: none;
         }

.title-row{
  display: -webkit-box;
  display: -ms-flexbox;
  -webkit-flex-wrap: wrap;
      -ms-flex-wrap: wrap;
          flex-wrap: wrap;
  margin: 40px 0;
  width: calc(100vw - 80px);
  box-sizing: border-box;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
      -ms-flex-pack: justify;
          justify-content: space-between;
          overflow-x: scroll;
  white-space: nowrap;
  overflow: auto;
 white-space:nowrap;
 width: 100%;
}

.titles-wrapper {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-wrap: wrap;
      -ms-flex-wrap: wrap;
          flex-wrap: wrap;
  margin: 40px 0;
  width: calc(100vw - 80px);
  box-sizing: border-box;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
      -ms-flex-pack: justify;
          justify-content: space-between;
}
.TitleList[data-loaded='true'] {
  opacity: 1;

}

.Item {
  width: calc(20% - 10px);
  min-width: calc(20% - 10px);
  background-color: #ffffff;
  -webkit-box-flex: 1;
 -webkit-flex: 1 0 auto;
     -ms-flex: 1 0 auto;
         flex: 1 0 auto;
  background-position: center;
  background-size: 100%;
  height: 200px;
  background-repeat: no-repeat;
  overflow: hidden;
  margin-right: 10px;
  -webkit-transition: background 1s ease;
  transition: background 1s ease;
  display: inline-block;


}

0 个答案:

没有答案