How i make div with different sizes vertically in middle of page.
For example with 100px height.
like windows 8 messages.
Thnk you. Mohammad.
How i make div with different sizes vertically in middle of page.
For example with 100px height.
like windows 8 messages.
Thnk you. Mohammad.
If I understand the question, this is how one of the options DEMO
<div class="wrap">
<div class="block">text</div>
<div class="block">text</div>
<div class="block">text</div>
<div class="block">text</div>
<div class="block">text</div>
<div class="block">text</div>
<div class="block">text</div>
<div class="block">text</div>
</div>
.wrap {
width: 800px;
margin: 0 auto;
background: #ccc;
display:block;
overflow: hidden;
padding: 100px 0 0 0;
}
.block {
width: 100px;
height: 50px;
background: green;
margin: 10px auto;
display:block;
}
.block:nth-of-type(2) {
height: 80px;
}
.block:nth-of-type(4) {
height: 150px;
}
.block:nth-of-type(7) {
height: 20px;
}
Use margin:auto
in combination with position: absolute
. Then declare all the left/top/right/bottom as zero.
It only works if you have added a height
in your css.
It doesn't work for variable heights.
See this fiddle http://jsfiddle.net/mBBJM/1/