Я пытаюсь выполнить следующее использование CSS:
<table border="1" width="300px">
<tr>
<td rowspan="2">This row should equal the height (no fixed-height allowed) of the 2 rows sitting to the right.</td>
<td>Here is some sample text. And some additional sample text.</td>
</tr>
<tr>
<td>Here is some sample text. And some additional sample text.</td>
</tr>
</table>
Примеры я видел выполнение этого, используют зафиксированные высоты или позволяют содержанию переносить левый столбец. Существует ли изящный способ выполнить это использование CSS?
Во-первых, то, что вы делаете, мне кажется таблицей, так что вы можете подумать об этом. Однако сделать это с помощью CSS немного сложнее (если вы не стилизуете таблицу в CSS). Следующий код работает, но не центрирует текст в поле по вертикали:
<html><head><title>Test2</title></head><body>
<div style="width:300px; padding: 2px; border: 1px solid black;">
<div style="float:right; width: 100px;">
<div style="border: 1px solid black; margin-bottom: 2px;">
Here is some sample text. And some additional sample text.
</div>
<div style="border: 1px solid black;">
Here is some sample text. And some additional sample text.
</div>
</div>
<div style="border: 1px solid black; margin-right: 102px;">
<div>
This column should equal the height (no fixed-height allowed) of the 2 rows sitting to the right.
</div>
<div style="clear: right; margin-bottom: -1px;"></div>
</div>
</div></body></html>
Ячейки таблицы в CSS проще:
<!DOCTYPE html>
<html><head><title>Test2</title></head><body>
<div style="display: table; width:300px; border: 1px solid black; border-spacing: 2px;">
<div style="display: table-cell; border: 1px solid black; vertical-align: middle;">
This column should equal the height (no fixed-height allowed) of the 2 rows sitting to the right.
</div>
<div style="display: table-cell; width: 100px;">
<div style="border: 1px solid black; margin-bottom: 2px;">
Here is some sample text. And some additional sample text.
</div>
<div style="border: 1px solid black;">
Here is some sample text. And some additional sample text.
</div>
</div>
</div>
</body>
</html>
Вот что я использую: http://www.ejeliot.com/samples/equal-height-columns/example-7.html
Я бы просто использовал второй столбец как оболочка для двух других элементов (менее семантический). Это должен быть самый простой способ.