3. 버튼과 인풋 태그

김해준's avatar
Jan 10, 2026
3. 버튼과 인풋 태그
<!DOCTYPE html> <html lang="en"> <head> <title>Document</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <style> .red_btn { background-color: #ff5a5f; color: white; width: 80px; height: 45px; border: 0px; border-radius: 5px; font-size: 15px; font-weight: 700; } .red_shadow { box-shadow: 3px 3px 0px 0px rgb(172, 154, 154); } .red_outline_btn { background-color: white; color: black; width: 80px; height: 45px; border: 1px solid black; border-radius: 5px; font-size: 15px; font-weight: 700; } .input_search { color: white; border: 1px solid #f4f4f4; box-shadow: -1px -1px 0px 0px #9d9d9d; border-radius: 3px; } .google_login { background-color: white; color: black; width: 300px; height: 50px; border: 1px solid black; border-radius: 5px; font-size: 15px; font-weight: 700; } </style> </head> <body> <h1>상세 디자인 (버튼, 인풋태그)</h1> <hr /> <!-- 요즘은 input:button은 잘 안씀 --> <!-- css에서 변수이름은 스네이크법을 따른다 --> <button class="red_btn">검색</button> <button class="red_btn red_shadow">로그인</button> <button class="red_outline_btn">회원가입</button> <hr /> <input class="input_search" type="text" placeholder="🔎 Search..." /> <hr /> <button class="google_login"> <i class="fa-brands fa-google"></i> 구글 계정으로 로그인 </button> </body> </html>
notion image
이 예제는 HTML 기본 구조 위에서
CSS를 이용해 버튼과 input 태그를 스타일링하고,
Font Awesome 아이콘 라이브러리를 사용하는 방법을 정리한 코드다.

1️⃣ 전체 코드 목적

  • <button> 태그를 이용한 버튼 디자인
  • <input> 태그 커스터마이징
  • 외부 아이콘 라이브러리(Font Awesome) 사용
  • CSS 클래스 조합을 통한 스타일 재사용

2️⃣ Font Awesome 라이브러리 추가

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />

✔ 역할

  • 아이콘을 이미지가 아닌 폰트 형태로 제공
  • <i> 태그와 클래스만으로 아이콘 사용 가능
  • 색상, 크기, 정렬을 CSS로 제어 가능

✔ 사용 예

<iclass="fa-brands fa-google"></i>

3️⃣ 버튼 스타일 정의

🔹 기본 빨간 버튼

.red_btn { background-color:#ff5a5f; color: white; width:80px; height:45px; border:0px; border-radius:5px; font-size:15px; font-weight:700; }
  • 배경색이 있는 기본 버튼
  • 고정 크기 + 둥근 모서리
  • 강조용 버튼에 적합

🔹 그림자 효과 (클래스 조합)

.red_shadow { box-shadow:3px3px0px0pxrgb(172,154,154); }
<buttonclass="red_btn red_shadow">로그인</button>
  • 기존 버튼에 추가 효과만 덧붙이는 구조
  • 하나의 요소에 여러 클래스 적용 가능
  • 스타일 재사용에 유리한 방식

🔹 외곽선 버튼

.red_outline_btn { background-color: white; color: black; width:80px; height:45px; border:1px solid black; border-radius:5px; font-size:15px; font-weight:700; }
  • 배경 없는 버튼
  • 회원가입, 취소 버튼 등에 자주 사용됨

4️⃣ 입력창(input) 스타일링

.input_search { color: white; border:1px solid#f4f4f4; box-shadow: -1px -1px0px0px#9d9d9d; border-radius:3px; }
<inputclass="input_search"type="text"placeholder="🔎 Search..." />
  • 기본 input 디자인 커스터마이징
  • 음영을 이용해 살짝 들어간 느낌 표현
  • placeholder에 이모지 사용 가능

5️⃣ 소셜 로그인 버튼 예제

.google_login { background-color: white; color: black; width:300px; height:50px; border:1px solid black; border-radius:5px; font-size:15px; font-weight:700; }
<buttonclass="google_login"> <iclass="fa-brands fa-google"></i> 구글 계정으로 로그인 </button>
  • 아이콘 + 텍스트 버튼 구성
  • 실제 서비스에서 자주 사용하는 UI 패턴
  • Font Awesome 아이콘 활용 사례

6️⃣ HTML 태그 사용 포인트

✔ <button> 태그 사용

  • input type="button" 대신 <button> 사용
  • 내부에 텍스트 + 아이콘 자유롭게 배치 가능

✔ 클래스 네이밍

  • snake_case 방식 사용 (red_btn, google_login)
  • 연습 및 가독성 측면에서 명확한 네이밍

7️⃣ 정리

  • 버튼과 입력창의 기본 스타일링
  • CSS 클래스 분리와 조합
  • 외부 아이콘 라이브러리 사용
  • 실무에서 자주 쓰는 UI 패턴 연습
 
Share article