Jump to content
  • 0

Выравнивание ячеек таблицы по высоте


drdorian
 Share

Question

Здравствуйте.

Столкнулся с проблемой - есть таблица, в которой имеются ячейки, разные по высоте из-за контента. Поэтому высота ячеек получается разной. А нужно прижать один элемент к низу ячейки.Будь они одинаковой высоты - воспользовался бы

 position: absolute 

. А так все скачет и получается некрасиво. Есть какие либо варианты выравнивания ячеек по самой высокой в ряду?

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

vertical-align не прокатит, так как только один элемент должен быть прижат к низу, остальные к верху.

Ячейки то фактически по высоте одинаковые, но то что не хватает в меньших как будто дополняется паддингом. В итоге вписанный в ячейку div не растягивается на всю высоту, даже если указать height: 100%;

Сайт на локалке, а код выплёвывается Drupal'ом, поэтому скопировать его сюда проблематично.Слишком много его.

Link to comment
Share on other sites

  • 0

drdorian,

Ну блин, сделай прототип (пример). Ну или на крайняк скопируй из фаербага.

Как что-то можно посоветовать в слепую. По описани, мне например, вообще не понятно, что у тебя происходит.

Это нужно - http://chikuyonok.ru/2011/04/inline-vertical-align/ ?

Link to comment
Share on other sites

  • 0
Сайт на локалке, а код выплёвывается Drupal'ом, поэтому скопировать его сюда проблематично.Слишком много его.

Значит надо не полениться и сделать тестовую страницу с проблемным местом.

Link to comment
Share on other sites

  • 0

drdorian,

Ну блин, сделай прототип (пример). Ну или на крайняк скопируй из фаербага.

Как что-то можно посоветовать в слепую. По описани, мне например, вообще не понятно, что у тебя происходит.

Это нужно - http://chikuyonok.ru/2011/04/inline-vertical-align/ ?

Спасибо за совет, но у меня все таки таблица.Я в этом уверен на все 100 =)

Подготовлю тест, выложу.

Link to comment
Share on other sites

  • 0

<html>
<head>
<style>
table {
width: 400px;
}
table td {
width: 50%;
vertical-align: top;
}
.td_bottom {
margin-top: 10px;
}
</style>
</head>
<body>
<table>
<tr>
<td>
<div class="td_wrapper">
<div>
a lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of contenta lot of content
</div>
<div class="td_bottom">
some content to place at bottom
</div>
</div>
</td>
<td>
<div class="td_wrapper">
<div>
a bit of contenta bit of contenta bit of contenta bit of contenta bit of contenta bit of contenta bit of contenta bit of contenta bit of contenta bit of contenta bit of content
</div>
<div class="td_bottom">
some content to place at bottom
</div>
</div>
</td>
</tr>
</table>
</body>
</html>

например вот так.ширина таблицы ограничена, ширина ячеек то же постоянна.вопрос стоит в том чтобы прижать div.td_bottom к низу ячейки.

Edited by drdorian
Link to comment
Share on other sites

  • 0

В ячейке таблицы position: absolute; не работает, об этом ясно написано в спеке.

То есть только при статичной высоте ячейки? А каким образом?


<table style="height: 200px;">
<tr>
<td style="height: 100%;">
<div style="height: 100%; position: relative;">
<div style="position: absolute; bottom: 0;">я буду снизу в ячейке</div>
</div>
</td>
</tr>
</table>

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