Skip to content

Instantly share code, notes, and snippets.

@tyv
Created June 17, 2012 16:53
Show Gist options
  • Save tyv/2945052 to your computer and use it in GitHub Desktop.
Save tyv/2945052 to your computer and use it in GitHub Desktop.
в построении лэйаута
/*
в построении лэйаута
есть несоколько задач:
— расположить контент горизонтально
display: inline-block,
float: left,
position: absolute
таблица
— сделать так, чтобы контент
не переполнял колонку
min-width,
overflow,
таблица
— сделать так, чтобы колонки
никогда не проваливались одна
под другую
white-space: nowrap;
сумма ширин float-блоков
всегда равна или меньше
ширины родителя
— отступы, бордеры и фон
как правило вложенный элемент
чтобы не допустить ширины > 100%
(50% + 10px || + 10px 50%)
*/
body
{
font-size: 29px;
}
.container
{
/* предотвращаем налезание элементов */
min-width: 900px;
white-space: nowrap;
}
.left,
.center,
.right
{
display: inline-block;
/* включаем внутри обратно, наследуется */
white-space: normal;
vertical-align: top;
}
.left
{
width: 16%;
/*
невозможно сделать
min-margin 20px
*/
margin-left: 2%;
}
.center
{
width: 56%;
}
.right
{
width: 24%
margin-right: 2%;
}
<div class="container">
<div class="left">левая колонка</div
><div class="center">
средняя колонка<br>
более высокая, <br>
занимает 3 строки
</div
><div class="right">правая колонка</div>
</div>
{"view":"separate","fontsize":"110","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment