Div最下方
"div" 標籤是 HTML 中的一個元素,用於將文檔分成獨立的、獨特的部分。每個 "div" 標籤都可以有自己的樣式屬性,因此它們常用於創建布局。
如果你想將 "div" 標籤放在網頁的最下方,你可以使用 CSS 中的 "position: absolute;" 和 "bottom: 0;" 屬性來實現。以下是一個簡單的例子:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Div at the Bottom</title>
<style>
.container {
position: relative;
}
.fixed-div {
position: absolute;
bottom: 0;
width: 100%;
background-color: #f1f1f1;
padding: 20px;
}
</style>
</head>
<body>
<div class="container">
<!-- Your content here -->
</div>
<div class="fixed-div">
<p>This div is at the bottom of the page.</p>
</div>
</body>
</html>
在這個例子中,我們有一個包含內容的 ".container",還有一個 ".fixed-div" 位於網頁的最下方。".container" 設定了 "position: relative;",這使得我們可以使用 "position: absolute;" 相對於 ".container" 定位 ".fixed-div"。".fixed-div" 的 "bottom: 0;" 屬性確保了它始終位於網頁的最下方。
請注意,這個例子假設 ".container" 的內容不會改變網頁的高度。如果 ".container" 的內容導致網頁高度增加,那麼 ".fixed-div" 可能會移動到內容下方,而不是網頁的最下方。在這種情況下,你可能需要使用 JavaScript 來動態調整 ".fixed-div" 的位置。