Reputation: 21
I am using css sprites. I have a simple image and a text. I want to display the image in center of the page and the text to vertically center to that image. I am new to css, I couldn't find a way to do it.
The code I have is
<div class="sprite"></div>hi
.sprite {
width: 50px;
height: 72px;
background-image: url("http://s.cdpn.io/79/sprite-steps.png");
}
Upvotes: 1
Views: 941
Reputation: 32182
Define background
position
and one div
as like this
Css
.centerText{
float:left;
text-align:center;
}
.sprite {
width: 50px;
height: 72px;
background: url("http://s.cdpn.io/79/sprite-steps.png") 3px -6px;
}
HTML
<div class="centerText">
<div class="sprite"></div>hi
</div>
Upvotes: 2