-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.html_css_js_basic.html
More file actions
103 lines (82 loc) · 3.04 KB
/
Copy path5.html_css_js_basic.html
File metadata and controls
103 lines (82 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>html css js 통합 기본</title>
<link rel="stylesheet" href="css/mystyle.css">
<style>
/* 태그선택자 */
p{
color: gray;
}
/* 클래스 선택자 : 태그선택자보다 우선.*/
.c1{
color: blue;
text-align: center;
}
/* ID선택자 */
#id1{
color: red;
}
/* 자손선택자 : 자손 모두에게 영향 */
div h5{
color: green;
}
/* 자식선택자 : 직계자식에게만 영향 */
div > p {
color: yellow;
}
</style>
<script>
function updateDemo1() {
document.getElementById("demo1").innerHTML="hello world1"
}
// 이 경우에 script가 읽힐 때, load2가 존재하지 않아 실행안됨.
document.getElementById("load2").innerHTML="hello world load1"
</script>
<!-- 외부 js import시에 아래와 같이 선언한다. -->
<script src="js/myjs.js"></script>
</head>
<body>
<!-- css적용방법 3가지 : 인라인, 내부스타일, 외부스타일 -->
<p style="color: green; text-align: center; text-decoration: underline;">인라인 스타일 적용</p>
<!-- 내부스타일 적용 : 문서 전체에 대한 디자인을 head에 style태그 내에서 한꺼번에 지정 -->
<!-- 이 때 요소를 선택해야 하는데, 요소선택의 방법으로는 태그선택자, 클래스 선택자, id선택자 3가지 방법 -->
<p>태그 선택자 적용</p>
<p class="c1">클래스 선택자 적용</p>
<p class="c1">클래스 선택자 적용</p>
<!-- id는 문서전체에서 유일해야 함. -->
<p id="id1">ID 선택자 적용</p>
<!-- 외부스타일 적용 -->
<p id="external1">외부스타일 적용</p>
<!-- 자손선택자 : 하위(자손)태그 모두에게 영향 -->
<div>
<h2>자식선택자 예시</h2>
<h5>첫번째 단락</h5>
<section><h5>두번째 단락</h5></section>
</div>
<!-- 자식선택자 : 직계자식에게만 영향 -->
<div>
<h2>자식선택자 예시</h2>
<p>첫번째 단락</p>
<section><p>두번째 단락</p></section>
</div>
<h2>javascript 예시</h2>
<p id="demo1">변경될 내용1</p>
<button onclick="updateDemo1()">변경버튼1</button>
<p id="demo2">변경될 내용2</p>
<button onclick="updateDemo2()">변경버튼2</button>
<p id="demo3">변경될 내용3</p>
<button onclick="updateDemo3()">변경버튼3</button>
<h2>js 로드 순서</h2>
<p id="load1">js 로드1</p>
<p id="load2">js 로드2</p>
<script>
document.getElementById("load2").innerHTML="hello world load2"
function updateDemo2() {
document.getElementById("demo2").innerHTML="hello world2"
}
</script>
</body>
</html>