Simplest vertical alignment we can think of

后端 未结 5 917
情书的邮戳
情书的邮戳 2021-01-06 13:32

To sum it up, there are few approaches to align content vertically in container. These are main approaches (if you now some completely different way to do it, it would be ve

5条回答
  •  渐次进展
    2021-01-06 14:22

    If you know the height of what you are centering you can use absolutely position the box 50% from the top and then use a negative margin half the height of the box to center it. It's annoyingly complex getting it to work it ie7 but it does work.

    http://css-tricks.com/snippets/css/exactly-center-an-imagediv-horizontally-and-vertically/

    Example:

    .center {
        width: 300px;
        height: 300px;
        position: absolute;
        left: 50%;
        top: 50%; 
        margin-left: -150px;
        margin-top: -150px;
    }
    

提交回复
热议问题