How do I align text to the middle of an element with CSS in Twitter Bootstrap?

不想你离开。 提交于 2019-12-03 02:54:35

Make the line-height of the div the same as the height of the div, eg:

#UploadSuccess { height: 20px; line-height: 20px; }

This will only work if you have one line of text.

Trying to vertically center text text is a common issue. Normally this wouldn't work on normal boxes, but you can force it to work with vertical align:

vertical-align: middle;
display: table-cell;

However this will not work in IE7 and lower.

If you are sure the text you want to display you could use line-height to fake the effect like this:

height: 40px;
line-height: 40px; /* same as height */

This way works cross browser and has support up to IE5.5 I believe. If this is not an option I'm afraid you're out of luck (it can't be done).

As a side note that error message suffers from bad grammar, it should be "Congratulations! You have successfully done it.".

Make it easier ;) ! Try to use alert-block ! That works fine with latest Bootstrap version !

<div class="alert alert-block alert-success" id="UploadSuccess">
    <a class="close" data-dismiss="alert">×</a>
    <strong>Congrats!</strong> You have successfully did it!.
</div>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!