所以我把這個絕對定位的div放在頁面的中心。我希望在這個div下面放置一個導航菜單,但是我無法將其與其他div嵌套。無論如何要做到這一點?將一個div放在一個絕對定位的div下面,而不是嵌套
注意:在片段代碼示例中,位置absolute:bottom;
不起作用,但您明白了。
HTML:
<div class="content">Hello world</div>
<div class="menu">home | info | about us | contact</div>
CSS:
body {
position:relative;
}
.content {
position: absolute;
top: 10px;
bottom: 30px;
left: 10px;
right: 10px;background:grey;
min-height:400px;
}
.menu {
background:blue; width:100%; text-align:center;
}
「我希望把這個div下方的導航菜單,但我不能與其他分區窩吧。」爲什麼你必須嵌套它? div是一個塊元素,所以當你在div後面放一個div時,它會出現在它的下面。 – desbest
'.content'是不變的高度嗎? – Justinas
內容不是一個不變的高度。這使得很難 –