How to use vertical align in bootstrap

后端 未结 8 2172
北恋
北恋 2020-11-29 22:29

Simple problem: How do I vertically align a col within a col using bootstrap? Example here (I want to vertically align child1a and child1b):

http://bootply.com/7366

8条回答
  •  长情又很酷
    2020-11-29 22:56

    Prinsen's answer is the best choice. But, to fix the issue where the columns don't collapse his code needs to be surrounded by a media check statement. This way these styles are only applied when the larger columns are active. Here is the updated complete answer.

    HTML:

    img
    text

    CSS:

    @media (min-width: 768px){
       .display-table{
           display: table;
           table-layout: fixed;
       }
    
       .display-cell{
           display: table-cell;
           vertical-align: middle;
           float: none;
       }
    }
    

提交回复
热议问题