EX_01. Display
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#naver2{
display: none;
}
#naver:hover+#naver2 {
display: inline;
}
#daum2{
display: none;
}
#daum:hover+#daum2{
display: inline;
}
</style>
</head>
<body>
<a href="https://www.naver.com/" id="naver">네이버</a>
<sup id="naver2">www.naver.com</sup>
<br>
<a href="https://www.daum.net/" id="daum">다음</a>
<sup id="daum2">www.daum.net</sup>
</body>
</html>
EX_02. Margin
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
width: 100px;
height: 100px;
}
#red{
background-color: red;
}
#yellow{
margin-left: 100px;
background-color: blue;
}
#blue{
background-color: green;
margin-left: 200px;
}
#green{
background-color:gray;
margin-left: 300px;
}
</style>
</head>
<body>
<div id="red"></div>
<div id="yellow"></div>
<div id="blue"></div>
<div id="green"></div>
</body>
</html>
EX_03. 신호등 만들기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#red, #yellow, #green{
width: 100px;
height: 100px;
border-radius: 50px;
}
#black{
background-color: black;
border-radius: 20px;
width: 120px;
height: 360px;
padding-top: 10px;
box-sizing: border-box;
}
#red{
background-color: red;
margin: 10px;
}
#yellow{
background-color: yellow;
margin: 10px;
}
#green{
background-color: green;
margin: 10px;
}
</style>
</head>
<body>
<div id="black">
<div id="red"></div>
<div id="yellow"></div>
<div id="green"></div>
</div>
</body>
</html>
EX_04. Position
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
width: 100px;
height: 100px;
}
#redBox{
background-color: red;
position: absolute;
top:0;
left: 0;
}
#yellowBox{
background-color: yellow;
position: absolute;
top:0;
right: 0;
}
#blueBox{
background-color: blue;
position: absolute;
bottom: 0;
left: 0;
}
#greenBox{
background-color: green;
position: absolute;
bottom: 0;
right: 0;
}
</style>
</head>
<body>
<div id="redBox"></div>
<div id="yellowBox"></div>
<div id="blueBox"></div>
<div id="greenBox"></div>
</body>
</html>
EX_05. Layout
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Layout</title>
<style>
#bg{
width: 500px;
height: 500px;
position: relative;
}
.header{
width: 500px;
height: 10%;
position: relative;
top: 0px;
background-color: #ea4335;
}
.nav{
height: 10%;
position: relative;
top: 50;
background-color: #ff5e00;
}
.side{
width: 30%;
height: 60%;
position: absolute;
top: 100px;
left: 0px;
background-color: #4285f4;
}
.section1{
height: 30%;
position: relative;
top: 100;
background-color: #34a853;
}
.section2{
height: 30%;
position: relative;
top: 200;
background-color: #fbbc05;
}
.footer{
height: 20%;
position: relative;
top: 300;
background-color: #8a8d92;
}
</style>
</head>
<body>
<div id="bg">
<div class="header"></div>
<div class="nav"></div>
<div class="section1"></div>
<div class="section2"></div>
<div class="footer"></div>
<div class="side"></div>
</div>
</body>
</html>
'FRONT-END > HTML CSS' 카테고리의 다른 글
HTML 예제 (0) | 2022.07.13 |
---|---|
HTML /CSS 환경 구축 (0) | 2022.07.06 |