Last active
February 17, 2018 08:21
-
-
Save SarathSantoshDamaraju/451195abf3fdfdd30e1d7fe1426a23ce to your computer and use it in GitHub Desktop.
CSS -- Centre align text to an image
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
/* Responsive */ | |
https://codepen.io/SarathSantoshDamaraju/pen/aqyjWa | |
/* Not responsive layout, but image size is responsive. */ | |
/* | |
<div> | |
<img src="" alt=""/> | |
<p> </p> | |
</div> | |
*/ | |
div{ | |
height:100%; | |
display: table; | |
} | |
div img { | |
max-width: 400px; | |
min-width:280px; | |
width:auto; | |
} | |
div > * { | |
display:table-cell; | |
vertical-align:middle; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment