html - position image in center square and fill the remaining space with colour -


i want position image center square , fill in remaining space colour. below code though, image on top , text "test" right below image. want text outside 120x120 square.

i tried below code:

css (included in head):

.img-container {     width: 120px;     height: 120px;     display: inline-block;     overflow: hidden;     background-color:#000; } .img-container img {     width: 100%;     height: 100%; } 

html:

<a class="img-container" href="http://google.com"><img src="http://couponcoupon.biz/image/logo/landmsupply.com.jpg" /> test </a> 

look @ article: http://coding.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css/ has great breakdown of absoulte center:

.absolute-center {     margin: auto;     position: absolute;     top: 0;     left: 0;     bottom: 0;     right: 0; } 

a fiddle applied example: http://jsfiddle.net/bhlaird/xgnxa/ moved text down negative bottom: setting. i'm not wild it, i'd add wrapper div around img-container have text below it, didn't want change markup much.

.img-container span {     position:absolute;     bottom: -20px;     left:0;right:0; } 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -