2016-10-31 10 views
0

У меня есть шаблон чата с заголовком (список пользователей чата, Я не знаю высоты заголовка, это зависит от количества людей, поэтому фиксированная высота не является сделкой) и нижний колонтитул (поле textarea сообщения). Между этими двумя divs я хочу размещать сообщения. Использование display: table для parent и display: table-row с высотой 1px для верхнего и нижнего колонтитула хорошо работает только в браузерах webkit, firefox и IE, игнорируя это. Есть example. Есть ли способ сделать рабочее поведение во всех браузерах (webkit, firefox, IE8 +)?Прокручиваемый div с верхним и нижним колонтитулом

Свойства Flexboxes и calc не могут использоваться из-за поддержки старых браузеров.

+0

какой-либо причине вы все еще поддерживают ie8, когда Microsoft перестали поддерживать его? – Pete

+0

Да, у меня есть некоторые причины из-за слабых компьютеров (даже с Windows XP на доске), которые будут использовать этот чат. – Iworb

ответ

0

*{margin:0; 
 
\t padding:0; 
 
\t } 
 
body{ 
 
\t background:#fff; 
 
\t position:absolute; 
 
\t width:100%; 
 
\t height:100%; 
 
\t } 
 
.main{ 
 
\t background:#0C0; 
 
\t height:100%; 
 
\t padding:60px 0 40px; 
 
\t box-sizing:border-box; 
 
\t } 
 
.header{ 
 
\t background: #0FC; 
 
\t position:absolute; 
 
\t width:100%; 
 
\t height:60px; 
 
\t } 
 
.left{ 
 
\t background:#3CC; 
 
\t float:left; 
 
\t width:250px; 
 
\t height:100%; 
 
\t overflow:scroll; 
 
\t } 
 
.right{ 
 
\t background:#9F3; 
 
\t height:100%; 
 
\t overflow:scroll; 
 
\t } 
 
.footer{ 
 
\t background:#9F9; 
 
\t position:absolute; 
 
\t bottom:0; 
 
\t width:100%; 
 
\t height:40px; 
 
\t }
<div class="header"></div> 
 
<div class="main"> 
 
    <div class="left">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div> 
 
    <div class="right">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div> 
 
</div> 
 
<div class="footer"></div>

+0

Невозможно использовать заголовок со статической высотой, потому что _it зависит от количества людей, поэтому фиксированная высота не является сделкой – Iworb

0

@Iworb

Я не понимаю вашу полную вещь, но я надеюсь, что я близко, чтобы решить вашу проблему.

Live View Solution

Вы можете решить проблему путем использования этого CSS:

.messages-wrapper .messages-panel #messages-form { 
    display: table-row; 
    height: auto; 
    position: absolute; 
    bottom: -15px; 
    background: #F5F5F5; 
    width: 100%; 
} 

NB: Это Поддерживаемые все браузер.

+0

Это полный код чата, который открывается в окне iframe. Я выполнил ваше решение в [source] (http://jsbin.com/nikedu/edit?html,css,output), но ничего не изменилось. Firefox по-прежнему выглядит одинаково - div с сообщениями без прокрутки, но теперь появляется форма. – Iworb

+0

@Iworb Спасибо, я получил ваше обновление. Пожалуйста, добавьте этот стиль также 'width: 100%; ' –

+0

Тогда вы увидите что-то. –

0

@Iworb

Просто взгляните:

решаемые Ваша проблема Используя простой JQuery функции. Надеюсь, это поддерживается всеми браузерами.

Live view

var clientHeight = $(window).height(); 
var z = clientHeight - '40'; 
var c = clientHeight - '150'; 
    $('.conversations-list').css('max-height', z); 

    $('.messages-container').css('max-height', c); 
Смежные вопросы