我的問題是這樣的。我有一個父母div
這是100%
。我有另外的3 divs
的寬度爲20%
,60%
和20%
,它們總共填充了父母div
。現在我的問題是我想打開button
點擊一個視圖。 button
在寬度爲60%
的中間div
中實現。我想打開的視圖應該覆蓋整個頁面。但是因爲我的中間div
是60%
它只擴展了60%,使頁面的其他部分留空。從子div內訪問父div的寬度
那麼我怎樣才能放置在100%
寬度停留在兒童div
這是60%的看法。
我這是怎麼顯示在click
的觀點:
return (
<div className="middle_div">
<input className='post_data_input' placeholder="Ask your question here" ref="postTxt" onClick={this.popup_ques}/>
{this.state.showComponent ? <QuestionOverlay/> : null}
</div>
);
即時顯示按鈕的視圖中單擊
render() {
return (
<div id="overlay">
</div>
)
}
export default QuestionOverlay;
CSS
父DIV
.body_clr{
background-color: #eceff1;
position: fixed;
overflow-y: scroll;
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
孩子的div
.middle_div{
width: 60%;
height: 100%;
margin-top:20%;
float: left;
margin-left: 2%;
margin-right: 2%;
position: relative;
}
新觀點
#overlay{
background:rgba(0,0,0,.75);
position: relative;
width: 100%;
height: 100%;
opacity:1;
-webkit-transition: opacity .25s ease;}
它工作嗎? –