Reputation: 8836
I am having a difficulty on how to center a text in a div with background image. This is my fiddle
Thank you.
Upvotes: 1
Views: 779
Reputation: 50493
Just declare line-height
and set the <a>
to be vertical-align: middle
.balloon{
background:url('http://i.imgur.com/B19Zb.jpg');
background-repeat: no-repeat;
text-align: center;
color:#fff;
font-size:1.1em;
height:140px;
width:140px;
line-height: 118px;
}
.balloon a{
vertical-align: middle;
color:yellow;
text-align:center
}
<div class="balloon">
<a href="#">Advertise with us</a>
</div>
Upvotes: 1
Reputation: 78530
display: table-cell;
text-align: center;
vertical-align: middle;
one option is to you display:table-cell
The image and size and such needs fixed though.
Upvotes: 0