твои тестовые примеры работают в точности так, как ты описываешь, поэтому всё у тебя работает ;)
для начала можешь открыть для себя тег style, position: absolute|relative, bottom: 0px, гугл |
Делаю вот так
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
html {
height: 100%;
}
body {
margin: 0;
padding: 0;
height: 100%;
}
#main {
position: relative;
height: 100%;
border: solid 1px blue;
min-height: 100%;
}
#sidebar {
position: absolute;
top: 50px;
left: 0px;
width: 30%;
height: 100%;
border: solid 1px red;
}
#content {
position: absolute;
top: 50px;
right: 0px;
width: 70%;
height: 100%;
border: solid 1px green;
}
#message {
position: absolute;
bottom: 0px;
right: 0px;
width: 100%;
height: 10%;
border: solid 1px black;
}
#header {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
border: solid 1px yellow;
height: 50px;
}
</style>
</head>
<body>
<div id="main">
<div id="header"></div>
<div id="sidebar">сидебар</div>
<div id="content">
контент
<div id="message">мессаге</div>
</div>
</div>
</body>
</html>
но div-sidebar, div-content, div id-message выходят за границы div-main. Если убрать у div-sidebar, div-content top: 50px, то они накладываются на div-header. Как вариант уменьшить у этих div'ов height, но хотелось, чтобы заполняли всю область, чтобы у других пользователей нормально отображалось. |
опиши для каждого из блоков (header, footer, content, sidebar): что должно произойти, когда высота их содержимого превысит их высоту
а также header, footer должны ли быть всё время на экране или просто являются крайними |
Цитата:
content, sidebar - ну тут должен появиться скролл, overflow: auto Цитата:
|
Цитата:
<!doctype html>
<style>
body {
height: 100%;
margin: 0px;
padding: 0px;
}
#header {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
background: red;
z-index: 100;
}
#content {
position: relative;
height: 100%;
border: solid 1px green;
padding-top: 1em;
padding-bottom: 1em;
}
#footer {
position: fixed;
left: 0px;
bottom: -2em;
width: 100%;
background: yellow;
}
</style>
<div id="header">header</div>
<div id="content">
<a href="#" class="sh">show/hide footer</a>
</div>
<div id="footer">footer</div>
<script>
(function () {
var content = document.getElementById("content");
for (var i = 1; i <= 100; i++) {
content.innerHTML += "<br/>" + i;
}
document.getElementsByClassName("sh")[0].onclick = function () {
var fs = document.getElementById("footer").style;
if (fs.bottom == "0em") {
fs.bottom = "-2em";
} else {
fs.bottom = "0em";
}
}
})();
</script>
|
Я не ахти какой спец в css (если что, мой ник к каскадным таблицам стилей не имеет никакого отношения), но, если я верно помню, то display:block заставляет див занимать всю доступную область. И ещё надо бы обнулить стили.
И ещё я бы добавила:
*{box-sizing:border-box;}
Последнее я добавляю, чтоб не манаться с просчётом всяких мэржинов и пэддингов. |
Цитата:
|
Цитата:
|
Цитата:
|
Цитата:
|
| Часовой пояс GMT +3, время: 02:37. |