Jump to content
  • 0

Высота div !!!


kpp
 Share

Question

Высота div

Если задать выстоу div в 100%, то он получается в 100% от экрана браузера. У меня див лежит в табличке с отступами по 25px сверху и снизу и высотой с окно браузера.

В результате див начинается сверху как надо, с 25px сверху, но снизу он выползает "мама не горюй!". Он вылезает вниз на 25px

Что делать??? Если это дело таблицами верстать, как всю жизнь и приходится. Ибо див неуправляем по сравнению с таблицей, она понимает как надо встать, когда ей говорят высота 100%, она становится на 100% от возможного... в текущем. А див выходит за пределы БУДТО БЫ POSITION ABSOLUTE!

Вот такие жуткие пироги. С этим делом я мирился до тех пор, пока не потребовалось быстро загружать таблички, а они в IE сразу не отображаются. Следовательно надо div-ами.

ХОТЬ СТО-НИБУДЬ ПОСОВЕТУЙТЕ,

писать это изврат, он мне не помогает, вложенных много таблиц.
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Теперь задумайся: от чего слой бер?т 100% высоты? Если прочитать спецификацию, то от первого ближайшего родителя с абсолютным или относительным позиционированием. Так что задай своей ячейке position: relаtive; и вс? будет ОК!

Link to comment
Share on other sites

  • 0
<html>
<head>
<title>test</title>
</head>
<body cellpadding=0 cellspacing=0>

<table style="height:100%;border:2px solid red;padding:10px;position:relative">
<tr>
<td style="position:relative">
<div style="height:25px;border:1px solid green;position:relative">
header div
</div>
<div style="height:100%;border:2px solid black;padding:10px;position:relative">
main div
</div>
<div style="height:25px;border:1px solid green;position:relative">
footer div
</div>
</td>
</tr>
</table>
</body>
</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy