2017-04-11 51 views
0

我的HTML看起来像以下:阵营DIV志愿服务岗位

return (
<div> 
    <If condition={this.state.showFullSizedImage}> 

     {/* Main div with full sized background image */} 
     <div className="div-one"> 
     </div> 

     {/* Product details div */} 
     <If condition={!this.state.showRegistration && !this.state.showLogin}> 
     <div className="div-five"> 

      </div> 
     </If> 

     {/* Show half page registration */} 
      <If condition={this.state.showRegistration}> 
       <div className="div-two"> 

       </div> 
      </If> 

      {/* Show half page login */} 
      <If condition={this.state.showLogin}> 
       <div className="div-three"> 

       </div> 
      </If> 

      {/* Show half page Password forget */} 
      <If condition={this.state.showPwdForgot}> 
       <div className="div-four"> 

       </div> 
      </If> 
     </If> 
     </div> 
    ); 

SCSS:

.div-one { 
    background: url("../../../assets/images/manhattan-min.png") no-repeat center center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 

    position: fixed; 
    width: 100%; 
    min-height: 500px; 
    min-height: 100vh; 
    display: block; 
} 
.div-two { 
    position: fixed; 
    width: 50%; 
    height: 100vh; 
    background-color: #EEEEEE; 
    -webkit-animation: left-to-right-div2 0.2s forwards; 
    animation: left-to-right-div2 0.2s forwards; 
} 
.div-three { 
    position: fixed; 
    width: 50%; 
    height: 100vh; 
    background-color: #EEEEEE; 
    -webkit-animation: left-to-right-div3 0.2s forwards; 
    animation: left-to-right-div3 0.2s forwards; 
} 
.div-four { 
    position: fixed; 
    width: 50%; 
    height: 100%; 
    background-color: #EEEEEE; 
    -webkit-animation: left-to-right-div3 0.2s forwards; 
    animation: left-to-right-div3 0.2s forwards; 
} 

.div-five{ 
    position: absolute; 
    min-height: 250px; 
    min-height: 50vh; 
    background-color: brown; 
    display: block; 

} 

我想实现的是:

我的DIV一应具全屏幕DIV下面我应该看到div-five。有一个在DIV-一个按钮,clicked- DIV-两个或DIV-三格四应与DIV-一个沿开到50%的宽度像以下时:

enter image description here

眼下div-一,二,三和四正确渲染。但是div-five不能因为它和其他div的位置不匹配。

我该怎么办?

+0

似乎比反应更一个css问题。 –

+0

由于div 2,3,4的条件加载,我把它放在了反应中。只有第一和第五格,固定位置和相对位置更容易。 – Nitish

+0

是否可以在点击按钮时动态制作div-one宽度50%? – Nitish

回答

0

不知道这是否会产生任何影响,但是您没有为.div-five设置任何宽度(您为高度设置了两个值)。由于你的div是emtpy(在你的示例代码中)并且没有宽度,我认为它被渲染,但是没有任何宽度。

但是,你应该能够看到这个在控制台..

+0

如果我把它放在相对位置并给出顶部:说100vh然后我可以看到它,但问题是:当我向下滚动div时,一个保持固定,div-5与它重叠 – Nitish