<head>
태그 안에 <link>
태그를 이용하여 css 파일을 적용<head>
<link rel="stylesheet" href="stylesheet.css" />
</head>
<head>
태그 안에 <style>
태그를 이용하여 css 적용selector(식별자) {property(속성) : value(값);}
<head>
<title>Home - My first website</title>
<style>
div {
height: 150px;
width: 150px;
background-color: tomato;
}
span {
background-color: turquoise;
}
</style>
</head>
<body>
<h1 style="color : tomato;">RED VELVET</h1>
</body>
CSS에는 크게 두 가지 박스(블록 박스와 인라인 박스) 유형이 있다.
block
및 inline
과 같은 [display](https://developer.mozilla.org/ko/docs/Web/CSS/display)
속성 값으로 정의display
속성을 이용해 Block과 Inline 요소의 성질을 변경할 수 있다padding
은 콘텐츠 주변을 마치 공백처럼 자리padding
의 크기는 padding과 관련 속성을 사용해 제어Border
박스는 contents
와 padding
까지 둘러싼다.Border
의 크기와 스타일은 border와 관련 속성을 사용하여 제어margin
은 가장 바깥 쪽 레이어로 contents와 패딩, border
를 둘러싸면서 박스와 다른 요소 사이 공백 역할margin
박스의 크기는 margin과 관련 속성을 사용하여 제어Margin
- box의 border
(경계)의 '바깥'에 있는 공간magin
은 속성 값의 수에 따라 적용되는 위치가 다르다.블록의 top 및 bottom 마진은 때로는 경우에 따라 제일 큰 여백의 크기를 가진 단일 여백으로 결합(상쇄(collapsed))됩니다. - MDN
Padding
- box의 border(경계)의 '안쪽'에 있는 공간padding
속성값도 margin
과 동일하게 적용padding
이 좌우에만 적용된다.<body>
<div id="first">
<div id="second">
<div id="third">
<div id="fourth"></div>
</div>
</div>
</div>
</body>
div {
height: 150px;
width: 150px;
padding: 10px;
}
#first {
background-color: whitesmoke;
width: 150px;
height: 150px;
}
Syntax: <line-width> || <line-style> || <color>
id
는 고유하며 1개의 요소만 선택 가능class
는 요소들을 그룹지어 동일한 내용을 적용할 때 사용body {
height: 100vh;
margin: 20px;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
justify-content
는 main axis(default: 수평)를 담당align-items
는 cross axis(default: 수직)를 담당축을 수정하고 싶은 경우 flex-direction
을 column으로 변경
화면크기 변화에도 요소의 사이즈를 변형하지 않고 다음 줄로 가게하고 싶으면 flex-wrap
사용
FlexBox 익히기 게임 : 🐸flex-box-froggy