Como centralizar verticalmente alinhar imagem de fundo com texto?
Estou tendo problemas para alinhar verticalmente a imagem de fundo com o texto, sem atribuir valores constantes (e, portanto, não automáticos e reutilizáveis)height
ouline-height
. Eu queria saber se há realmente uma maneira de alinhar verticalmente bg imagem de, digamos ea
elemento, with its text without assigning constant values to
altura da linhaor
height`?
Uma demonstração ao vivo está disponível aqui:http://cssdesk.com/8Jsx2.
Aqui está o HTML:
<a class="">background-position: center</a>
<a class="contain">background-size: contain</a>
<a class="line-height">Constant line-height</a>
E aqui está o CSS:
a {
display: block;
margin: 10px;
width: 200px;
padding-left: 34px;
font-size: 14px;
background: url('http://cdn1.iconfinder.com/data/icons/freeapplication/png/24x24/Thumbs%20up.png');
background-repeat: no-repeat;
background-position: 5px center;
border: 1px solid black;
}
/* I don't want to use constant line-height */
.line-height {
line-height: 24px;
}
/* I don't want to use this, because I want my bg image's size to stay intact */
.contain {
background-size: contain;
}