h1 {
color: red;
}
{}
안에 작성/* 주석 내용 */
<head>
<style>
h1 { color: red; }
</style>
</head>
<link rel="stylesheet" href="style.css">
.css
<h1 style="color: red;">제목</h1>
*
전체 선택자h1
태그 선택자#id
아이디 선택자.class
클래스 선택자[속성]
, [속성=값]
속성 선택자h1, p, div {}
div > p {}
div p {}
h1 + p {}
h1 ~ p {}
선택자::before { content: "텍스트"; }
선택자::after { content: "텍스트"; }
:link
, :visited
:hover
, :active
:focus
, :checked
, :disabled
, :enabled
구조적 선택자 예시:
E:first-child
E:last-child
E:nth-child(n)
E:nth-of-type(n)
E:nth-last-of-type(n)
E:first-of-type
E:last-of-type
절대 단위: px, cm 등
상대 단위:
%
: 상위 요소 기준em
: 부모 폰트 크기 기준rem
: html 폰트 크기 기준vw
: 뷰포트 너비 기준vh
: 뷰포트 높이 기준#ff0000
font-family: '돋움', sans-serif;
font-size: 16px;
font-weight: bold;
font-style: italic;
font-variant: small-caps;
color: red;
text-align: center;
text-decoration: underline;
letter-spacing: 1px;
line-height: 1.5;
요소의 성격:
div
, p
, h1
a
, span
img
, button
등background-color: #eee;
background-image: url('img.png');
background-size: cover;
background-position: center center;
background-attachment: fixed;
background 속성 한 줄 요약
background: url('img.png') center/cover no-repeat fixed;
position: static | relative | absolute | fixed;
top: 10px;
left: 20px;
float / clear 속성
float: left;
clear: both;
transition-property: all;
transition-duration: 0.5s;
transition-delay: 0s;
transition-timing-function: ease-in-out;
타이밍 함수 종류:
linear
, ease
, ease-in
, ease-out
, ease-in-out
cubic-bezier(x1, y1, x2, y2)
@keyframes move {
from { left: 0; }
to { left: 100px; }
}
.box {
animation-name: move;
animation-duration: 2s;
animation-delay: 0s;
animation-iteration-count: infinite;
animation-play-state: running;
}
transform: translate(50px, 100px);
transform: scale(1.2, 0.8);
transform: rotate(45deg);
Google Fonts 적용 예시
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
아이콘 폰트 (Font Awesome 등)
간단한 <i class="fa fa-icon">
사용으로 아이콘 표현 가능