0
我有三個子div,並希望中間div忽略父div的寬度,並採取全屏寬度(但它需要保持其位置低於第一格)我怎麼能有第二個div行忽略父div的寬度
我有三個子div,並希望中間div忽略父div的寬度,並採取全屏寬度(但它需要保持其位置低於第一格)我怎麼能有第二個div行忽略父div的寬度
使用position: absolute
標籤解決了這個問題。見JSfiddle:https://jsfiddle.net/sachingpta/3qu3m466/。示例代碼
`
html,body{
height: 100%;
padding: 0px;
margin: 0px;
}
.parent{
width: 300px;
height: 100%;
background-color: grey;
margin: 0 auto;
}
.child1{
background-color: red;
}
.child2{
background-color: green;
position: absolute;
left: 0px;
right: 0px;
}
.child3{
background-color: blue;
}
`
您可以定義中間的孩子寬度在vw
定義的寬度:
.parent {
width: 100px;
height: 40px;
background: blue;
}
.child {
width: 100%;
background: yellow;
}
.overflower {
width: 100vw;
background: red;
}
<div class=parent>
<div class=child>child</div>
<div class=overflower>overflows</div>
<div class=child>child</div>
</div>
如果你有一些代碼,這是比較容易幫助。 –
得到它解決看到[jsfiddle](https://jsfiddle.net/sachingpta/3qu3m466/),謝謝。 – SACn
@SachinGupta你最好刪除那個問題。山姆是對的,你的問題太模糊了:有很多方法可以解決問題,但其中大多數不符合你的真實(不成文)要求 –