width 속성을 사용하여 요소의 너비 조정
CSS의 너비 속성을 사용하여 요소의 너비를 지정할 수 있습니다. 값은 상대 길이 단위(예: em), 절대 길이 단위(예: px) 또는 포함하는 상위 요소의 백분율로 제공될 수 있습니다. 다음은 이미지의 너비를 220px로 변경하는 예입니다.
img { width: 220px; }
전체 카드에 width 속성을 추가하고 절대값 245px로 설정합니다. fullCard 클래스를 사용하여 요소를 선택합니다.
<style> h4 { text-align: center; } p { text-align: justify; } .links { margin-right: 20px; text-align: left; } .fullCard { width: 245px; border: 1px solid #ccc; border-radius: 5px; margin: 10px 5px; padding: 4px; } .cardContent { padding: 10px; } </style> <div class="fullCard"> <div class="cardContent"> <div class="cardText"> <h4>Google</h4> <p>Google was founded by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University.</p> </div> <div class="cardLinks"> <a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank" class="links">Larry Page</a> <a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank" class="links">Sergey Brin</a> </div> </div> </div>
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.