Align Text Beside FontAwesome Icon

后端 未结 6 1567
旧时难觅i
旧时难觅i 2021-01-17 15:10

Hi I\'m having trouble trying to align text beside a font awesome icon I\'ve tried a few things but non of them seem to be working what i\'m trying to do is make a panel wit

6条回答
  •  长发绾君心
    2021-01-17 15:54

    For posterity, if you are willing to go with CSS flexbox, aligning icons besides text is trivial.

    I've kept Bootstrap and its Panel as part of the solution in the spirit of answering the original question.

    The key points to note here are:

    • display: flex to make direct children flow in the default direction (row)
    • align-items: center to align along the flex direction (vertical align in this case)
    • flex: 1 to get the middle section to expand as much as possible, pushing the two sides apart

    .banner {
      display: flex;
      align-items: center;
    }
    
    .banner-start h3 {
      display: inline-block;
    }
    
    .banner-start i {
      padding: 0 6px;
    }
    
    .banner-middle {
      flex: 1;
    }
    
    
    

提交回复
热议问题