나는 다음과 같은 시각적 효과를 달성하기 위해 노력하고있어 나는 여러 가지를 시도했지만 그것을 할 수 없습니다했습니다이미지를 다른 요소와 관련하여 수직으로 정렬하는 방법은 무엇입니까?
. 여기 codepen에 그것의 가장 단순화 된 버전이다 : 그것은 codepen입니다
링크에. HTML은 다음과 같습니다
<div class="outerContainer">
<button>LOREM IPSUM</button>
<!-- This is the question mark image -->
<img src="http://i60.tinypic.com/adoqiv.png">
</div>
CSS의는 다음과 같습니다
// Just to see the border for testing
$test-border-width: 3px;
$test-border-style: dotted;
.outerContainer {
border: $test-border-width $test-border-style green;
// Don't span entire width because later will center container
display: inline-block;
button {
border: $test-border-width $test-border-style red;
// I would like to be able to change the font size
// without having to worry about the question mark image,
// that is, for the image to be automatically vertically aligned
// in the middle.
font-size: 4em;
}
img {
border: $test-border-width $test-border-style cyan;
}
}
조언이 크게 감사합니다. 또한 가능하다면 그 뒤에있는 추론.
훌륭한 작품. 왜 그것이 효과가 있는지 설명해 주시겠습니까? – SBel
[vertical-align] (http://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align) 속성 만 사용합니다. 두 요소에 모두 추가하여 수직 정렬이 더 긴 요소에 상대적입니다. –