Tôi muốn thiết kế cấu trúc cho trang web nhưng tôi gặp sự cố mà tôi không thể duy trì nó. Đây là những gì tôi muốn:Tạo cấu trúc trang web có chân trang ở dưới cùng và nội dung 100%
một trang web với 3 phần:
1-header
2-content(has 2 parts, a sidebar and a content section)
3-footer
và tôi muốn những đặc điểm này:
1- if in the content section there is nothing then footer stays at the bottom, if we have content, footer pushes down and stays after my content
2- my sidebar(exist in the content section) take 100% height of content section and connects to footer
như thế này:
tôi xây dựng này với mã này và nó hoạt động, nhưng vấn đề của tôi là nếu nội dung của sid ebar khu vực được lớn hơn, bên và khu vực nội dung chính chồng chéo footer! Tôi muốn rằng trong tình huống này, chân trang vẫn sau nội dung của tôi.
Tôi sử dụng Twitter Bootstrap cho công việc của mình. Tôi không muốn sử dụng các phương thức chỉ có sẵn trong các trình duyệt mới. ít nhất là IE 9.
đây là mã của tôi:
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap.min.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container-fluid">
<div class="row header">
<div>header</div>
</div>
<div class="row content">
<div class="col-lg-2 sidebar">
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
</div>
<div class="col-lg-10">content</div>
</div>
<div class="row footer">
<div>footer</div>
<div>footer</div>
<div>footer</div>
<div>footer</div>
<div>footer</div>
</div>
</div>
và đây là CSS:
body,html{
height: 100%;
}
.container-fluid {
height:100%;
}
.header{
background-color: #ccff55;
}
.content{
background-color: #445566;
height: -webkit-calc(100% - 10%);
}
.sidebar{
background-color: #446655;
height: 100%;
}
.footer{
background-color: #11ff99;
}
trùng lặp càng tốt này của [Làm thế nào để bạn có được chân để ở lại ở dưới cùng của một trang web? ] (http://stackoverflow.com/questions/42294/how-do-you-get-the-footer-to-stay-at-the-bottom-of-a-web-p tuổi) – connexo
Đây là một sử dụng tuyệt vời của tài sản 'calc' ... 100% - 10%. Haha ... bạn đã thử 90% chưa? Haha ... –
@connexo: không có điều này không phải là tôi muốn và đây không phải là một bài đăng trùng lặp. bài đăng mà bạn đã đề cập là một nửa câu hỏi của tôi, chỉ cần đặt chân trang ở cuối. tôi muốn 100% nội dung quá – Fcoder