Created
February 17, 2016 14:42
-
-
Save d1i1m1o1n/49809e4d7b5ea015bc59 to your computer and use it in GitHub Desktop.
Vertically align an image inside div (Вертикальное выравнивание по центру картинки в диве)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class=frame> | |
<span class="helper"></span><img src="http://jsfiddle.net/img/logo.png" height=250 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span><img src="http://jsfiddle.net/img/logo.png" height=25 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span><img src="http://jsfiddle.net/img/logo.png" height=23 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span><img src="http://jsfiddle.net/img/logo.png" height=21 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span><img src="http://jsfiddle.net/img/logo.png" height=19 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span> | |
<img src="http://jsfiddle.net/img/logo.png" height=17 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span> | |
<img src="http://jsfiddle.net/img/logo.png" height=15 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span> | |
<img src="http://jsfiddle.net/img/logo.png" height=13 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span> | |
<img src="http://jsfiddle.net/img/logo.png" height=11 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span> | |
<img src="http://jsfiddle.net/img/logo.png" height=9 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span> | |
<img src="http://jsfiddle.net/img/logo.png" height=7 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span> | |
<img src="http://jsfiddle.net/img/logo.png" height=5 /> | |
</div> | |
<div class=frame> | |
<span class="helper"></span> | |
<img src="http://jsfiddle.net/img/logo.png" height=3 /> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.frame { | |
height: 25px; /* equals max image height */ | |
width: 160px; | |
border: 1px solid red; | |
white-space: nowrap; | |
text-align: center; margin: 1em 0; | |
} | |
.helper { | |
display: inline-block; | |
height: 100%; | |
vertical-align: middle; | |
} | |
img { | |
background: #3A6F9A; | |
vertical-align: middle; | |
max-height: 25px; | |
max-width: 160px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment