Javascript-форум (https://javascript.ru/forum/)
-   (X)HTML/CSS (https://javascript.ru/forum/xhtml-html-css/)
-   -   Как растянуть div между нижней и верхней панелью? (https://javascript.ru/forum/xhtml-html-css/61765-kak-rastyanut-div-mezhdu-nizhnejj-i-verkhnejj-panelyu.html)

shurik_shink 07.03.2016 11:10

Как растянуть div между нижней и верхней панелью?
 
WEB странница состоит из трех элементов
I - верхняя панель <div> прижатая к потолку страницы (style="position:absolute; top:0px;")
II - нижняя панель <div> прижатая к низу страницы (style="position:absolute; bottom:0px;")
III - <div name="content" style="overflow-y: scroll;"> с контентом который находится между верхней и нижней панелью

Как растянуть <div name="content"> четко между верхней и нижней панелью?

destus 07.03.2016 11:13

А высота есть у верха и низа?

shurik_shink 07.03.2016 12:02

Цитата:

Сообщение от destus (Сообщение 410167)
А высота есть у верха и низа?

Да, фиксированная, по 1.5em

destus 07.03.2016 12:28

shurik_shink,
<body>
    <style>
        body {
            position: relative;
            margin: 0;
            padding: 0;
            min-height: 100%;
        }
        div {
            border: 1px solid black;
            width: 100%;
            box-sizing: border-box;
            text-align: center;
        }
        #header {
            position: absolute;
            top: 0;
            height: 1.5em;
        }
        #content {
            padding: 1.5em 0;
            min-height: 100%;
        }
        #footer {
            position: absolute;
            bottom: 0;
            height: 1.5em;
        }
    </style>
    <div id="header">Header</div>
    <div id="content">Content</div>
    <div id="footer">Footer</div>
</body>

рони 07.03.2016 12:43

destus,
может добавить
html, body{
         height: 100%;
       }
иначе не растянет

рони 07.03.2016 12:45

destus,
а зачем строка 21?

destus 07.03.2016 12:49

рони,
чтоб не наезжал на шапку и подвал

рони 07.03.2016 13:52

destus,
не танцует у меня твой пример

shurik_shink 07.03.2016 13:59

Цитата:

Сообщение от рони (Сообщение 410178)
destus,
может добавить
html, body{
         height: 100%;
       }
иначе не растянет

Прописал в style для html и body {height:100%} и заработало - растянуло как надо

С min-height не растягивает

рони 07.03.2016 14:03

destus,
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style>
       html, body{
         height: 100%;
       }

        body {
            position: relative;
            margin: 0;
            padding: 0;
            min-height: 100%;
        }
        div {
            border: 1px solid black;
            width: 100%;
            box-sizing: border-box;
            text-align: center;
        }
        #header {    background-color: #008000;
            position: absolute;
            top: 0;
            height: 1.5em;
        }
        #content {    background-color: #FFD700;

            min-height: 100%;
        }
        #footer {    background-color: #00BFFF;
            position: absolute;
            bottom: 0;
            height: 1.5em;
        }
    </style>
</head>

<body>

    <div id="header">Header</div>
    <div id="content">Content</div>
    <div id="footer">Footer</div>
</body>


</html>


Часовой пояс GMT +3, время: 16:10.