Issue
I have 2 elements, a title and an icon contained in a card.
Title is center aligned horizontally and icon is right aligned horizontally.
But now I want to vertically align both items in the middle.
<div class='card center-align'>
<span class='card-title'>Title</span>
<i class='material-icons right'>delete</i>
</div>
.card {
width: 500px;
height: 100px;
vertical-align: middle;
}
Demo here: https://jsfiddle.net/mn3Ldyc7/4/
Been pulling my hair out trying out different methods, but still can't get it perfectly aligned. Any help greatly appreciated!!
Solution
Another solution using flex :
.card {
width: 500px;
height: 100px;
display: flex;
align-items: center;
}
.card-title {
flex: 1
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/1e005331dc.js"></script>
<div class='card center-align'>
<span class='card-title'>Title</span>
<i class='material-icons right'>delete</i>
</div>
Answered By - Temani Afif Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.