>  기사  >  웹 프론트엔드  >  `` 요소는 명시적인 'line-height' 없이 어떻게 수직 텍스트 정렬을 달성합니까?

`` 요소는 명시적인 'line-height' 없이 어떻게 수직 텍스트 정렬을 달성합니까?

Linda Hamilton
Linda Hamilton원래의
2024-10-26 07:29:30788검색

How Do `` Elements Achieve Vertical Text Alignment Without Explicit `line-height`?

<버튼>의 수수께끼 같은 세로 정렬 요소

웹 개발의 세계에서는 <버튼> 요소는 텍스트를 수직 중앙에 유지하는 겉보기에 마법 같은 능력 때문에 종종 우리를 당황하게 합니다. 이 수수께끼를 풀기 위해 HTML과 CSS의 일부를 분석해 보겠습니다.

<code class="html"><button class="button">Some Text</button>
<div class="button">Some Text</div></code>
<code class="css">.button {
  background: darkgrey;
  height: 40px;
  border: 2px solid grey;
  width: 100%;
  box-sizing: border-box;
  font-size: 14px;
  font-family: helvetica;
  text-align: center;
  margin-bottom: 20px;
}</code>

이 시나리오에서

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.