일정한 (따라서 자동 및 재사용 할 수없는) 상수 값을 height
또는 line-height
에 지정하지 않고 배경 이미지를 텍스트와 수직으로 정렬하는 데 문제가 있습니다. 내가 실제로 어떻게 수직으로 중심 정렬하는 방법인지 궁금 해서요, 그리고 a
요소 , with its text without assigning constant values to
라인 높이 or
높이`의 bg 이미지를 정렬?배경 이미지를 텍스트와 세로로 정렬하는 방법은 무엇입니까?
라이브 데모는 여기에서 확인할 수 있습니다. http://cssdesk.com/8Jsx2.
다음은 HTML입니다 :
<a class="">background-position: center</a>
<a class="contain">background-size: contain</a>
<a class="line-height">Constant line-height</a>
그리고 여기에 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;
}
중복 가능성 [DIV 내부 중심 화상 세로되다 (http://stackoverflow.com/questions/2237636/how-to-vertically-center-image-inside- div) – JabberwockyDecompiler