2. CSS

CSS Class(클래스) 태그 간단하게 줄이기

도피디 2024. 11. 18. 22:56
반응형

공통적으로 적용되는 것을

class 태그로 모으기

<!DOCTYPE html>
<html lang="kr">
<head>
<title>The Nick Times</title>
<style>
body {
margin: 20px;
}
.btn {
padding: 5px 10px;
border-radius: 5px;
}
.teal {
background-color: teal;
}
.tomato {
background-color: tomato;
color: white;
}
</style>
</head>
<body>
<span class="btn teal">hello</span>
<span class="btn tomato"> hello</span>
<span class="btn teal">hello</span>
<span class="btn tomato">hello</span>
<span class="btn teal">hello</span>
<span class="btn tomato">hello</span>
<span class="btn teal">hello</span>
</body>
</html>

 

 

 

 

결과

오 버튼같아..!

반응형