Заставить высоту деления зависеть от высоты другого деления?

0

У меня есть "навигационный" div, который представляет собой список ссылок, перемещаемых слева от страницы. Рядом с ним справа находится "текст содержания" текста. Естественно, их высота зависит от содержимого внутри.

Поэтому "навигационный" div всего 5 ссылок намного короче, чем "абзац" содержимого. (это цветные прямоугольники на фоне белого, вот почему я пытаюсь их выстроить)

Я бы хотел, чтобы они были одинаковой высоты, чтобы они выстроились в линию. Конечно, я мог бы вручную указать высоту пикселя для обоих из них, однако я бы хотел, чтобы этот CSS файл использовался на нескольких HTML-страницах, где текстовое содержимое варьируется от 2-5 абзацев, а ручное указание не будет работать.

Показать ещё 2 комментария
Теги:

1 ответ

3

Пожалуйста, проверьте ниже ответ.

HTML

<div class="container clearfix">
<div class="sidebar">
    <ul>
        <li>link1</li>
        <li>link1</li>
        <li>link1</li>
        <li>link1</li>
    </ul>
</div>
<div class="content">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry 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.</p>
    <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
</div>

CSS

.container{border:1px red solid; position:relative;}
.sidebar {float:left;width:150px;border:1px green solid;position:absolute;top:0;bottom:0;left:0;}
.sidebar ul{list-style:none;padding:0;margin:0;}
.content{float:left;width:300px;border:1px orange solid;margin-left:160px;}
.clearfix:before, .clearfix:after { content: " "; display: table; }
.clearfix:after { clear: both; }
.clearfix { *zoom: 1;}

Ниже приведен скрипт моего кода. Вы можете решить это многими способами, я только что упомянул об этом.

http://jsfiddle.net/murli2308/htZhG/

  • 0
    Красиво сделано. Почему .clearfix {* zoom: 1;} требуется?
  • 0
    Clearfix очищает поплавок ..
Показать ещё 4 комментария

Ещё вопросы

Сообщество Overcoder
Наверх
Меню