How to center align ion icon inside button?

user4227915

I have this html structure:

<ion-view view-title="Items">
<ion-content>

<div class="card">
    <a href="#/app/item1" class="item item-text-wrap item-button-left">
        <button class="button circle text-center">
            <i class="ion-crop"></i>
        </button>
        Item 1
    </a>
</div>

<div class="card">
    <a href="#/app/item2" class="item item-text-wrap item-button-left">
        <button class="button circle text-center">
            <i class="ion-social-buffer"></i>
        </button>
        Item 2
    </a>
</div>

</ion-content>
</ion-view>

And I've added this custom css:

.circle {
    background-color: #00f;
    border-radius: 100%;
    border: 1px solid #00f;
    width: 50px!important;
    height: 50px;
    color: #fff;
}
.circle i {
    position: absolute;
    margin: auto;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

But it displays this way:

enter image description here

How can I do the cards to take the correct height and the ion-icons to the button's center?

Thanks for your time.

Tomek Buszewski

You can either set text-align to center and line-height to 50% or try this:

.circle {
    background: blue;
    width: 50px;
    height: 50px;
    position: relative;
    border-radius: 100%;
}

.icon {
    position: absolute;
    top: 50%;
    left: 50%;
    height: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    display: block;
    background: red;
}

Fiddle: http://jsfiddle.net/41eo0he7/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to center icon and text inside of a button?

From Java

How to align Big Icon at the center, inside smaller row in Flutter?

From Dev

How to vertical align icon inside label and button in the same way

From Dev

Align icon inside Material UI Button

From Dev

align icon on top of text inside button tag

From Dev

How to vertically align an icon inside a span

From Dev

How to align Floating Action Button to center

From Dev

How to center align a button and place it in front?

From Dev

How do I align a button to the bottom center?

From Dev

How to align button to center using Bootstrap

From Dev

How do I align a button to the bottom center?

From Dev

how to center align data list and its button

From Dev

How to center a fontawesome icon inside a div element

From Dev

How to center an icon inside css shapes?

From Dev

How to center spans inside an Ionic ion-scroll

From Dev

Vertically center text with icon inside div-button

From Dev

Vertically center text with icon inside div-button

From Dev

Vaadin - Align icon on button

From Dev

How can I align my icon to be in center of my square box?

From Dev

How to align icon to the left and text to the center by using flex?

From Dev

How to align icon to the center in an <i> tag of fixed height

From Dev

Button not center align in Safari

From Dev

Center Align Submit button

From Dev

Center align button with bootstrap

From Dev

Unable to center align button

From Dev

center align icon in circle/disc

From Dev

How to center the text inside a Button regardless of drawableLeft?

From Dev

how to center the button inside a table cell

From Dev

How to vertically center a button and text inside a div

Related Related

HotTag

Archive