Easiest Way To Vertically Align, Horizontally Aligned Images?
What is the easiest, quickest way to vertically align differently sized horizontally aligned images? Everything on Google is not working for me or I'm not doing it right... I've tr
Solution 1:
Change the parent, #main
, to display:table-cell
.
#main {
padding: 10px;
display: table-cell;
width: auto;
background-color: red;
}
Then add vertical-align:middle
to .media
(working example here)
.media {
display: inherit;
vertical-align: middle;
}
Solution 2:
How to vertically align:
HTML
<divid="main"><divid="avatar"class="inner"><imgsrc="http://i.imgur.com/GgxBXAA.png" /></div><divclass="media inner"><imgsrc="http://i.imgur.com/GmT37TG.png" /></div></div>
CSS
body {
background-color: #e5e5e5;
}
#main {
padding: 10px;
display: inline-block;
width: auto;
background-color: red;
}
#avatar {
display: inherit;
}
.media {
display: inherit;
}
.mediaimg {
margin-left: 10px;
}
.inner{
width: 100%;
text-align: center;
}
Solution 3:
You use display:block. Is this what you want?
body {
background-color: #e5e5e5;
}
#main {
padding: 10px;
display: block;
width: auto;
background-color: red;
width: 100px;
margin: 0 auto;
}
#avatar {
display: inherit;
}
.media {
display: inherit;
}
.mediaimg {
margin-left: 10px;
}
Post a Comment for "Easiest Way To Vertically Align, Horizontally Aligned Images?"