I hav开发者_运维知识库e a div with several images inside, and I would like to center this vertically. I can give a specific width and height do the div. No prob. I also accept js if I must to. I'm just wondering, from the MAZE of those examples, can I have a simple one.
The div as width of 600 and height of 500.
Thanks in advance, MEM
Easy peasy. Say your div has id="myDiv". Then...
#myDiv {
position: absolute;
top: 50%;
margin-top: -250px; // half the height of #myDiv
}
...will center the div inside of its offset parent.
Half-scale demo (so that you don't have to make your window really big to properly see the effect)
Handle this problem simply, you can use padding to the div.
加载中,请稍侯......
精彩评论