Skip to content

Instantly share code, notes, and snippets.

@arup-b
Last active December 26, 2019 04:52
Show Gist options
  • Save arup-b/6381bc1b33b4a21402159d7b0b619ec6 to your computer and use it in GitHub Desktop.
Save arup-b/6381bc1b33b4a21402159d7b0b619ec6 to your computer and use it in GitHub Desktop.
Centering elements (other than texts) inside a <ion-col></ion-col> is painful. Apply the following CSS in your respective component level scss or global theme to align items centrally.
.center{
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-pack: center;
-moz-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-content: stretch;
-ms-flex-line-pack: stretch;
align-content: stretch;
-webkit-box-align: center;
-moz-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
};
<ion-row>
<ion-col class="center">
<!-- your element here -->
</ion-col>
</ion-row>
@programatom
Copy link

Thank you so so much

@zeam2003
Copy link

Gracias! / Thank You!

@moiBinke
Copy link

Best solution. Thanks!

@arup-b
Copy link
Author

arup-b commented Dec 26, 2019

@zeam2003

Gracias! / Thank You!

Glad to know that it came to your use.

@arup-b
Copy link
Author

arup-b commented Dec 26, 2019

Best solution. Thanks!

Glad to know that it came to your use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment