<style>
a, p, .greeting{
color: green;
}
span.greeting{
color: orange
}
input[type]{
border:3px;
}
</style>
<a href="#">네이버</a>
<p>단락</p>
<div class="greeting">안녕하세요.</div>
<span class="greeting">반갑습니다.</span
<style>
/* 그룹 선택자 */
a,
p,
.greeting {
color: green;
}
span.greeting {
color: orange;
}
/* 속성 선택자 : 속성명*/
input[type] {
border: 3px solid red;
}
/* 속성 선택자 : 속성값 */
input[type="number"] {
border-color: blue;
}
a[href^="tel"] {
background: gray;
}
a[href$="com"] {
background: olive;
}
a[href$=".net"] {
background: yellow;
}
</style>
<a href="https://www.naver.com">네이버</a>
<a href="https://daum.net">다음</a>
<a href="tel:010-1000-1000">전화 걸기</a>
<p>단락</p>
<div class="greeting">안녕하세요.</div>
<span class="greeting">반갑습니다.</span>
<hr />
<input type="text" />
<input type="number" />
선택자 : 상태, 조건, 위치
가상 클래스 : 위치
조건 선택자
상태 선택자
<style>
.box {
width: 150px;
height: 150px;
background: orange;
transition: all 0.5s;
}
.box:hover {
width: 300px;
height: 300px;
rotate: 270deg;
}
.text:focus {
background: yellow;
}
.tab-group{
width:400px;
display:flex;
align-items: center;
}
.tab-group input[type='radio'] {
display:none;
}
.tab-group label{
border: 1px solid #ccc;
padding: 20px 15px;
margin: 0 5px;
}
.tab-group input[type='radio']:checked + label {
border-color:black;
background: black;
color:white;
}
</style>
<div class="box"></div>
<input type="text" class="text">
<br>
<br>
<br>
<div class="tab-group">
<input type="radio" name="tab" value="menu1" id="tab-1">
<label for="tab-1">메뉴1</label>
<input type="radio" name="tab" value="menu2" id="tab-2">
<label for="tab-2">메뉴2</label>
<input type="radio" name="tab" value="menu3" id="tab-3">
<label for="tab-3">메뉴3</label>
</div>
<style>
ul::before{
content: '첫번째';
}
ul::after{
content: '마지막';
}
/* 기본값 색상 변경 */
textarea::placeholder{
color:red;
}
/* 드래그 색상 변경 */
.text::selection{
background:yellow;
}
</style>
<ul>
<li>메뉴1</li>
<li>메뉴2</li>
<li>메뉴3</li>
</ul>
<textarea placeholder="자기소개를 입력하세요..." rows="5" cols="50"></textarea>
<div class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Possimus sit vitae iste esse, id ad nostrum placeat, porro voluptates, iure et officia consequuntur? Consectetur optio saepe dolore, reiciendis perferendis ipsum?
</div>
<style>
.text1{
/* rgb함수, 헥사코드 */
/* color: rgb(255, 0, 0); */
/* color: #ff0000 */
color : #f00;
}
</style>
<div class="text1">abc</div>
<!-- em, rem -->
<style>
html{
font-size:30px; /* 1rem = 13px*/
}
.text1 {
font-size: 1rem;
}
.text2 {
font-size: 2rem;
}
.text3 {
font-size: 3rem;
}
.text-group{
font-size: 20px; /* 20px -> 1em */
}
.text4 {
font-size: 1em;
}
.text5{
font-size: 2em; /* 40px */
}
</style>
<div class="text1">ABC</div>
<div class="text2">DEF</div>
<div class="text3">GHI</div>
<div class="text-group">
<div class="text4">가나다</div>
<div class="text5">라마바</div>
</div>
content : 내용이 존재하는 위치
padding : 내부 여백, border 안쪽
border : 외곽선
margin : 외부 여백, border 바깥쪽
box-sizing 속성을 사용하여 너비와 높이의 기준
block 속성 태그 : 제한 X ( 상하좌우 가능 )
inline 속성 태그 : 제한 O ( 좌우 만 가능 )
margin 옵션 개수 차이
margin,padding 방향 지정 옵션
<style>
.box {
width: 150px;
height: 150px;
background : orange;
margin: 100px;
}
.box:nth-of-type(2){
background: blue;
}
.box:nth-of-type(3){
background: green;
}
.box:nth-of-type(4){
background: red
}
div.box{
display:inline;
}
span.box{
display:block;
}
</style>
<div class="box">A</div>
<div class="box">B</div>
<span class="box">C</span>
<span class="box">D</span>
<style>
.box {
width: 150px;
height: 150px;
background : orange;
margin: 100px;
}
.box:nth-of-type(2){
background: blue;
}
.box:nth-of-type(3){
background: green;
}
.box:nth-of-type(4){
background: red
}
div.box, span.box{
display:inline-block;
}
</style>
<div class="box">A</div>
<div class="box">B</div>
<span class="box">C</span>
<span class="box">D</span>
<!-- display: none -->
<style>
.box {
width: 150px;
height: 150px;
background : orange;
margin: 100px;
}
.box2{
background: blue;
}
.box:nth-of-type(3){
background: green;
}
.box:nth-of-type(4){
background: red;
}
div.box, span.box{
display:inline-block;
}
.box2{
display: none;
}
</style>
<div class="box">A</div>
<div class="box2">B</div>
<span class="box">C</span>
<span class="box">D</span>
<!-- visibility -->
<style>
.box {
width: 150px;
height: 150px;
background : orange;
margin: 100px;
}
.box2{
background: blue;
}
.box:nth-of-type(3){
background: green;
}
.box:nth-of-type(4){
background: red
}
div.box, span.box{
display:inline-block;
}
.box2{
visibility: hidden;
}
</style>
<div class="box">A</div>
<div class="box2">B</div>
<span class="box">C</span>
<span class="box">D</span>
<!-- display: flex 적용-->
<style>
body{
margin: 0;
}
ul{
margin:0;
padding: 0;
list-style-type: none;
height:100px;
}
ul li {
min-width: 100px;
}
li:nth-of-type(1){
background: red;
}
li:nth-of-type(2){
background: blue;
}
li:nth-of-type(3){
background: green;
}
.flex1{
display : flex;
}
</style>
<ul class="flex1">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<!-- flex-direction을 활용한 우 -> 좌 정렬 -->
<style>
body{
margin: 0;
}
ul{
margin:0;
padding: 0;
list-style-type: none;
height:100px;
}
ul li {
min-width: 100px;
}
li:nth-of-type(1){
background: red;
}
li:nth-of-type(2){
background: blue;
}
li:nth-of-type(3){
background: green;
}
.flex1{
display : flex;
flex-direction: row-reverse;
}
</style>
<ul class="flex1">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<!-- justify-content를 활용한 리스트 정렬 -->
<style>
body{
margin: 0;
}
ul{
margin:0;
padding: 0;
list-style-type: none;
height:100px;
}
ul li {
min-width: 100px;
}
li:nth-of-type(1){
background: red;
}
li:nth-of-type(2){
background: blue;
}
li:nth-of-type(3){
background: green;
}
.flex1{
display : flex;
}
.flex2{
display : flex;
justify-content: center;
}
.flex3{
display : flex;
justify-content: flex-end;
}
</style>
<h1>start</h1>
<ul class="flex1">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<h1>center</h1>
<ul class="flex2">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<h1>end</h1>
<ul class="flex3">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<!-- space-between, around, evenly 적용 -->
<style>
body{
margin: 0;
}
ul{
margin:0;
padding: 0;
list-style-type: none;
height:100px;
}
ul li {
min-width: 100px;
}
li:nth-of-type(1){
background: red;
}
li:nth-of-type(2){
background: blue;
}
li:nth-of-type(3){
background: green;
}
.flex4{
display: flex;
justify-content: space-between;
}
.flex5{
display: flex;
justify-content: space-around;
}
.flex6{
display: flex;
justify-content: space-evenly;
}
</style>
<h1>space-between</h1>
<ul class="flex4">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<h1>space-around</h1>
<ul class="flex5">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<h1>space-evenly</h1>
<ul class="flex6">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<!-- align-items : flex-start, flex-end, center -->
<style>
body{
margin: 0;
}
ul{
margin:0;
padding: 0;
list-style-type: none;
height:100px;
}
ul li {
min-width: 100px;
}
li:nth-of-type(1){
background: red;
}
li:nth-of-type(2){
background: blue;
}
li:nth-of-type(3){
background: green;
}
.flex7{
display: flex;
justify-content: space-evenly;
align-items: flex-start;
}
.flex8{
display: flex;
justify-content: space-evenly;
align-items: flex-end;
}
.flex9{
display: flex;
justify-content: space-evenly;
align-items: center;
}
</style>
<h1>align-items: flex-start</h1>
<ul class="flex7">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<h1>align-items: flex-end</h1>
<ul class="flex8">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<h1>align-items: center</h1>
<ul class="flex9">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>