简体   繁体   中英

Vertically center font awesome icon and text inside an <a> tag/router-link

I have a b-button which is basically a router-link/a tag which contents i'd like to center. I want the text to be underneath my font awesome icon and both of them should be horizontally and vertically centered but nothing seems to work.

     <b-button variant="primary" class="main-navigation-button primary-custom-color"
                          :to="{name: 'companyCarList'}">
          <i class="fas fa-car fa-4x icon-full-width"></i> 
          Text
     </b-button>

Style of my button:

 .main-navigation-button {
        border: solid 1px transparent;
        border-radius: 1rem;
        box-shadow: 3px 3px 5px #ccc;
        font-size: 2vmax;
        margin-bottom: 20px;
        width: 15vw;
        height: 15vw;
        min-width: 150px;
        min-height: 150px;
    }

Try that:)

.main-navigation-button primary-custom-color {
display:flex;
flex-direction:column;
justify-content: center;
align-items:center
}

small example -> https://codepen.io/AdamKniec/pen/jObzLRm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM