How do I vertically align text in a colorbox?

This question already has an answer here:

  • How to align content of a div to the bottom? 24 answers

  • You can vertically center text by setting its line-height property to the height of the element it's sitting in.

    #cboxTitle{
        position:absolute; 
        top:0; 
        left:0; 
        text-align:left; width:100%; 
        color:#999; 
        height: 38px;
        line-height: 38px;
    }
    

    This trick will only work if you know the height of your div , of course. There are other methods, but they're more complex.

    Another method that isn't linked is to set the div containing your text to position: relative; , then setting top to 50% minus the one half the height of the element. This is best done in Javascript.

    链接地址: http://www.djcxy.com/p/75776.html

    上一篇: 如何使用CSS将元素放置在另一个元素的底部?

    下一篇: 如何在彩盒中垂直对齐文本?