VScode, HTML, CSS, JS
(第一堂課我會先講一遍
之後上課時先都幫我一樣用好)
code的檔案都會在這裡
(左上角)
如果出現這個幫我點藍色的:
命名規則:你的檔案名稱.副檔名
目前會用到的有:
.html .css .js
5. 下載插件 (Live server)
點這裡
按第一個
5. 下載插件 (Live server)
6. 使用Live Server
Live server可以讓你跑你寫的網站,
並且會及時更新你新的code
(記得要先儲存)
右下角
接下來會在google打開你的網站
7. 一些快捷鍵 (以防有人不知道)
<標記名> 內容放在這裡 </標記名>
<h1> ;) </h1><!DOCTYPE html>
<html>
<head>
...
</head>
<body>
...
</body>
</html><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>vscode打上
! enter
<html lang = "en">
設定元素的語系,en是English
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html><meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
這裡可以改你螢幕的大小
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>idk what to put here</title>
<link href="./funny.png" rel="icon">
</head>
<body>
</body>
</html><title>
<link href="檔案目錄" rel="icon">
<meta name="author" content="mlgnotcool">
<meta http-equiv="refresh" content="10">
<meta name="keywords" content="idk what to put here ;)">
<meta name="description" content="我是內容 我是內容 我是內容 我是內容">用剛剛學的東西
做出一個可以運行的網頁
先不用內容 只要有title就好了
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="mlgnotcool">
<meta http-equiv="refresh" content="10">
<meta name="keywords" content="idk what to put here ;)">
<meta name="description" content="我是內容 我是內容 我是內容 我是內容">
<title>idk what to put here</title>
<link href="./funny.png" rel="icon">
</head>
<body>
</body>
</html>(不要抄 你們要自己寫寫看)
<img>
<iframe>
<ul>
<ol>
<table>
<h1> - <h6>
<p>
<br>
<hr>
<a>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="mlgnotcool">
<meta http-equiv="refresh" content="10">
<meta name="keywords" content="idk what to put here ;)">
<meta name="description" content="我是內容 我是內容 我是內容 我是內容">
<title>idk what to put here</title>
<link href="./funny.png" rel="icon">
</head>
<body>
</body>
</html><body>
<h1>我是h1</h1>
<h2>我是h2</h2>
<h3>我是h3</h3>
<h4>我是h4</h4>
<h5>我是h5</h5>
<h6>我是h6</h6>
</body><p>Hello 我是一個paragraph</p> <p>你有想過網站是如何做出來的嗎?你有曾經想做一個屬於自己的網站嗎?<br>
這門課會帶你從0開始,教你如何使用HTML、CSS、JavaScript,並一步一步帶著你寫出一個有美感網頁 ! 不管有沒有寫過程式,都可以來參加!<br>
這堂課最一開始會帶你學習HTML,帶著你學習如何使用HTML寫出最基礎的網頁!再來會帶你使用CSS來美化你的網頁,讓網頁瞬間升級 !<br>
最後教你用JavaScript讓網頁可以動起來,且在課程中都會搭配著小實作,讓大家更加熟悉學習到的東西。<br>
在課程的最後會讓大家自己設計一個網頁,也讓大家可以在課程的最後創造出屬於自己的網頁 !</p>
<h1>hello1</h1>
<br>
<h1>hello2</h1> <p>你有想過網站是如何做出來的嗎?你有曾經想做一個屬於自己的網站嗎?<hr>
這門課會帶你從0開始,教你如何使用HTML、CSS、JavaScript,並一步一步帶著你寫出一個有美感網頁 ! 不管有沒有寫過程式,都可以來參加!<hr>
這堂課最一開始會帶你學習HTML,帶著你學習如何使用HTML寫出最基礎的網頁!再來會帶你使用CSS來美化你的網頁,讓網頁瞬間升級 !<hr>
最後教你用JavaScript讓網頁可以動起來,且在課程中都會搭配著小實作,讓大家更加熟悉學習到的東西。<hr>
在課程的最後會讓大家自己設計一個網頁,也讓大家可以在課程的最後創造出屬於自己的網頁 !</p>
<h1>hello1</h1>
<hr>
<h1>hello2</h1><a href="https://mlgnotcool.github.io/about/">我的自我解紹網站!</a><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="mlgnotcool">
<meta name="keywords" content="成電38th 網頁班">
<meta name="description" content="我是內容 我是內容 我是內容 我是內容">
<title>網頁班</title>
<link href="./images/funny.png" rel="icon">
</head>
<body>
<h1>翁釩予</h1>
<h2>MLGnotCOOL</h2>
<br>
<h3>成功電研 38th 教學+網管</h3>
<hr>
<h1>關於我:</h1>
<hr>
<h2>我的興趣:</h2>
<h3>玩minecraft</h3>
<h3>打code</h3>
<h3>影片剪輯</h3>
<h3>打爵士鼓</h3>
<h4>(還有孤獨搖滾)</h4>
<h2>我的學術力:</h2>
<h3>競程</h3>
<h3>演算法</h3>
<h3>網頁設計</h3>
<h3>python</h3>
</body>
</html>
假設我這裡有一個檔案:
他的途徑就會是他在電腦中的位置:
所以就會是 "D:/desktop/網站/class"
那要怎麼從一個檔案走到另一個檔案呢?
(讓html知道我們的檔案在哪裡)
假設我們要從index.html走到funny.png:
一些要知道的小知識:
"." - 現在這個資料夾
"/" - 要走的途徑
".." - 返回上一層資料夾
所以就會是:(拿上禮拜的icon來當例子)
<link href="./images/funny.png" rel="icon"><img src="./images/funny.png">
找到你要的影片:
然後按右鍵 然後再按這個 >
<iframe width="1840" height="985" src="https://www.youtube.com/embed/LTqcz68lVNE" title="2分鐘以內速通麥塊,並且拿到台灣前三!(設定種子碼)" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> <h1>我的興趣:</h1>
<ul>
<li>玩minecraft</li>
<li>打code</li>
<li>影片剪輯</li>
<li>打爵士鼓</li>
</ul> <h1>我的前三歌曲:</h1>
<ol>
<li><a href="https://www.youtube.com/watch?v=PuMz4v5PYKc">Porter Robinson - Look at the Sky</a></li>
<li><a href="https://www.youtube.com/watch?v=FnhedPLxksQ">Kessoku band - UNITE</a></li>
<li><a href="https://www.youtube.com/watch?v=UEwjYcGe0WU">Kessoku band - Doppelganger</a></li>
</ol> <table>
<caption>成電38th上學期 社課資訊統計</caption>
<tr>
<th>\ </th>
<th>算法班</th>
<th>網頁班</th>
<th>python班</th>
</tr>
<tr>
<th>講師</th>
<td>吳承樺</td>
<td>翁釩予</td>
<td>蕭映宇、林瑋浩</td>
</tr>
<tr>
<th>人數</th>
<td>22</td>
<td>16</td>
<td>15</td>
</tr>
</table>用剛剛學的東西
做出一個HTML的網頁
(不要抄 你們要自己寫寫看)
做出一個自我介紹的網站 (盡量包含我剛剛有講的東西)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="mlgnotcool">
<meta name="keywords" content="成電38th 網頁班">
<meta name="description" content="我是內容 我是內容 我是內容 我是內容">
<title>網頁班</title>
<link href="./images/funny.png" rel="icon">
</head>
<body>
<h1>翁釩予</h1>
<h2>MLGnotCOOL</h2>
<img src="./images/pfp_bgremoved.png" width="100px">
<hr>
<h3>成功電研 38th 教學+網管</h3>
<hr>
<h1>關於我:</h1>
<ul>
<li><h2>我的興趣:</h2></li>
<ul>
<li>玩minecraft</li>
<li>打code</li>
<li>影片剪輯</li>
<li>打爵士鼓</li>
</ul>
<li><h2>我的學術力:</h2></li>
<ul>
<li>競程</li>
<li>演算法</li>
<li>網頁設計</li>
<li>python</li>
</ul>
</ul>
<hr>
<h1>我的前三歌曲:</h1>
<ol>
<li><a href="https://www.youtube.com/watch?v=PuMz4v5PYKc">Porter Robinson - Look at the Sky</a></li>
<li><a href="https://www.youtube.com/watch?v=FnhedPLxksQ">Kessoku band - UNITE</a></li>
<li><a href="https://www.youtube.com/watch?v=UEwjYcGe0WU">Kessoku band - Doppelganger</a></li>
</ol>
<h2>我的影片:</h2>
<iframe width="720" height="405" src="https://www.youtube.com/embed/LTqcz68lVNE" title="2分鐘以內速通麥塊,並且拿到台灣前三!(設定種子碼)" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</body>
</html><div>
<span>
(HTML註解)
+HTML複習
<div>
<h2>我是文字</h2>
<p>我是更多文字</p>
</div>
<h2>我是很<span>重要</span>的文字</h2>"重要"被包在一個span裡面>
<h3>我是很<span>重要</span>的文字</h3><!-- 你要註解的東西 --><!DOCTYPE html>
<html lang="en">
<head>
<title>網頁班</title>
</head>
<body>
<div>
<h2>我是文字</h2>
<p>我是更多文字</p>
</div>
<h3>我是很<span>重要</span>的文字</h3>
</body>
</html><標記名> 內容放在這裡 </標記名>
<h1> ;) </h1><!DOCTYPE html>
<html>
<head>
...
</head>
<body>
...
</body>
</html><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="mlgnotcool">
<meta http-equiv="refresh" content="10">
<meta name="keywords" content="idk what to put here ;)">
<meta name="description" content="我是內容 我是內容 我是內容 我是內容">
<title>idk what to put here</title>
<link href="./funny.png" rel="icon">
</head>走路徑我就不在講一遍
<h1>翁釩予</h1>
<h2>MLGnotCOOL</h2>
<br>
<img src="./images/pfp_bgremoved.png" width="100px">
<ul>
<li><h2>我的興趣:</h2></li>
<ul>
<li>玩minecraft</li>
<li>打code</li>
<li>影片剪輯</li>
<li>打爵士鼓</li>
</ul>
</ul>
<hr>
<h1>我的前三歌曲:</h1>
<ol>
<li><a href="https://www.youtube.com/watch?v=PuMz4v5PYKc">Porter Robinson - Look at the Sky</a></li>
<li><a href="https://www.youtube.com/watch?v=FnhedPLxksQ">Kessoku band - UNITE</a></li>
<li><a href="https://www.youtube.com/watch?v=UEwjYcGe0WU">Kessoku band - Doppelganger</a></li>
</ol>
<h2>我的影片:</h2>
<iframe width="720" height="405" src="https://www.youtube.com/embed/LTqcz68lVNE" title="2分鐘以內速通麥塊,並且拿到台灣前三!(設定種子碼)" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
文字
空格
圖片
無序list
有序list
嵌入
分行
連結
如何把HTML連到CSS檔案
CSS基礎架構
內聯 外嵌
選擇器
id
class
<div style="background:#FFFE8C">
<h2 style="color:red">我是文字</h2>
<p style="color:#FF7E69">我是更多文字</p>
</div>style="要改的東西: 要改成的值"
color - 文字顏色
background - 背景顏色
<!DOCTYPE html>
<html lang="en">
<head>
<title>網頁班</title>
<link href="./styles.css" rel="stylesheet">
</head>
<body>
<div style="background:#FFFE8C">
<h2 style="color:red">我是文字</h2>
<p style="color:#FF7E69">我是更多文字</p>
</div>
<h2>我是很<span style="color:red">重要</span>的文字</h2>
</body>
</html>
<head>
<link href="./styles.css" rel="stylesheet">
</head>這是檔案路徑 相信你們都會走了
檔案位置
標明說這個連到的
檔案是CSS檔案
選擇器 {
要更改的東西;
}
h1 {
color: red;
}選擇器可以是很多東西
ex: h1, p, div, img (前面有講過的都可以)
也可以是id, class (等一下會講)
選擇HTML中
h1這個東西 ->
<- 將它顏色改成紅色
<h1>我是文字 ;)</h1>h1 {
color: tomato;
}<div>
<h2>我是文字</h2>
<p>我是更多文字</p>
</div>div {
background: #FFFE8C;
}<h3>我是很<span>重要</span>的文字</h3>span {
color: red;
background: yellow;
}<body>
<div>
<h2>我是文字</h2>
<p>我是更多文字</p>
</div>
<h3>我是很<span>重要</span>的文字</h3>
</body>body {
background: lightblue;
color: tomato;
}<!DOCTYPE html>
<html lang="en">
<head>
<title>網頁班</title>
<link href="./styles.css" rel="stylesheet">
</head>
<body>
<div>
<h2>我是文字</h2>
<p>我是更多文字</p>
</div>
<h3>我是很<span>重要</span>的文字</h3>
</body>
</html>body {
background: lightblue;
}
div {
background: #FFFE8C;
}
h2 {
color: red;
}
p {
color: #FF7E89;
}
span {
color: red;
background: yellow;
} <div id="div1">
<h2 class="text">我是文字</h2>
<p class="text">我是更多文字</p>
</div>
<h2>我是很<span id="span1">重要</span>的文字</h2></body>id - 只能使用於一個上
class - 可以使用於很多個
.text {
color: red;
}
#span1 {
color: tomato;
background: yellow;
}class -> 用 .
id -> 用 #
<div id="div1">
<h2 class="text">我是文字</h2>
<p class="text">我是更多文字</p>
</div>
<h2>我是很<span id="span1">重要</span>的文字</h2></body><!DOCTYPE html>
<html lang="en">
<head>
<title>網頁班</title>
<link href="./styles.css" rel="stylesheet">
</head>
<body>
<div id="div1">
<h2 class="text">我是文字</h2>
<p class="text">我是更多文字</p>
</div>
<h2>我是很<span id="span1">重要</span>的文字</h2></body>
</body>
</html>body {
background: lightblue;
color: tomato;
}
.text {
color: red;
}
#span1 {
color: tomato;
background: yellow;
}解答:
color
opacity
background
text
選擇器 {
要更改的東西;
}
h1 {
color: red;
}<h2 id="text">我是文字</h2>#text {
color: red;
}h1 {
color : tomato;
color: RGB(255, 99, 71);
color: #ff6347;
color: hsl(0, 100%, 50%);
}h1 {
color : yellow;
}h1 {
color: RGB(255, 99, 71);
}#000000
這個叫做hex code
每格代表一個1-16 (0~F) 的數字
每兩格代表一個數字
#紅色 綠色 藍色
每個顏色會有16*16=256種強度
h1 {
color: #ff6347;
}h1 {
color: hsl(0, 100%, 50%);
}<body>
<div id="div1">
<h2>我是<span id="red-text">紅色</span>文字</h2>
</div>
</body>body {
background-color: lightblue;
}
#div1 {
background-color: lightyellow;
}
#red-text {
background-color: red;
}
<h1 id="text1">我是文字1</h1>
<h1 id="text2">我是文字2</h1>
<h1 id="text3">我是文字3</h1>
<h1 id="text4">我是文字4</h1>#text1 {
background-color: lightblue;
opacity: 0.1;
}
#text2 {
background-color: lightblue;
opacity: 0.4;
}
#text3 {
background-color: lightblue;
opacity: 0.7;
}
#text4 {
background-color: lightblue;
opacity: 1.0;
}
#text1 {
background-color: rgba(173, 216, 230, 0.1);
}
#text2 {
background-color: rgba(173, 216, 230, 0.4);
}
#text3 {
background-color: rgba(173, 216, 230, 0.7);
}
#text4 {
background-color: rgba(173, 216, 230, 1.0);
}
(和上週差不多,我就不給範例code了)
<h2 id="text">我是文字</h2>#text {
color: red;
}對 就是我們剛剛介紹的
<h2 id="text">我是文字</h2>#text {
font-family: monospace;
}改變文字的字體
<!-- 以下的文字不是我自願加的 -->
<!-- 我來看有沒有人看得懂我在幹嘛 -->
<h2 id="text1">君と集まって星座になれたら</h2>
<h2 id="text2">いつまでも いくつまでも</h2>
<h2 id="text3">ドッペルゲンガーは言った</h2>#text1 {
font-size: 60px;
}
#text2 {
font-size: 40px;
}
#text3 {
font-size: 20px;
}改變文字的大小
px -> 像素
<h2 id="text1">君と集まって星座になれたら</h2>
<h2 id="text2">ドッペルゲンガーは言った</h2>#text1 {
font-style: normal;
}
#text2 {
font-style: italic;
}
改變文字的樣子 (變斜體)
<h2 id="text1">君と集まって星座になれたら</h2>
<h2 id="text2">いつまでも いくつまでも</h2>
<h2 id="text3">ドッペルゲンガーは言った</h2>#text1 {
font-weight: normal;
}
#text2 {
font-weight: lighter;
}
#text3 {
font-weight: bold;
}
改變文字的樣子 (變粗體、細體)
<h2 id="text1">君と集まって星座になれたら</h2>
<h2 id="text2">いつまでも いくつまでも</h2>
<h2 id="text3">ドッペルゲンガーは言った</h2>#text1 {
text-align: start;
}
#text2 {
text-align: center;
}
#text3 {
text-align: right;
}
width
height
background-image
border
<div id="big-text">
<h1 id="text1">我是文字1</h1>
<h1 id="text2">我是文字2</h1>
</div>#big-text {
background-color: lightblue;
width: 500px;
height: 250px;
}div {
width: 50px;
width: 50%;
width: 50vw;
height: 50vh;
height: 2em;
height: 2rem;
}width: 寬度
height: 長度
div {
width: 50px;
}div {
width: 50%;
}母元素 :元素上面一層的元素,
例如div包著h1,那個div就是h1的母元素
div {
width: 50vw;
height: 50vh;
}viewport:視窗大小
舉例來說:viewport 50px 寬,1vw = 0.5px
div {
width: 2em;
height: 2rem;
}em:
對於元素的母元素的font-size比例
舉例來說:2em = 2倍母元素的font-size
很重要,em和rem可以做出不會跑版的東西
body {
background-image: url("./images/wallpaper.png");
}語法:url("圖片路徑")
body {
background-image: url("./images/wallpaper.png");
background-repeat: no-repeat;
background-size: cover;
}background-repeat: no-repeat;
讓圖片不會重複
background-size: cover;
讓放大縮小不會影響它
border - 邊框
可以更改我們元素的邊框
#big-text {
background-color: lightblue;
width: 30%;
height: 30%;
border-style: solid;
}有很多種border-style,可以自己點連結看看
(我不會一個一個講,應該也記不起來 )
#big-text {
background-color: lightblue;
width: 30%;
height: 30%;
border-style: solid;
border-width: 10px;
}更改邊框的寬度
#big-text {
background-color: lightblue;
width: 30%;
height: 30%;
border-style: solid;
border-color: tomato;
}#big-text {
background-color: lightblue;
width: 30%;
height: 30%;
border-style: solid;
border-radius: 5px;
}更改邊框的圓角邊框
用我們目前交的東西,來幫我們的網站加個美編
ex: 背景圖片,邊框,背景顏色等
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>網頁班</title>
<link href="./styles.css" rel="stylesheet">
</head>
<body>
<div class="whole">
<div id="top">
<h1>翁釩予</h1>
<h2>MLGnotCOOL</h2>
<br>
<img src="./images/pfp_bgremoved.png" width="100px">
</div>
<br>
<div id="interests">
<ul>
<li><h2>我的興趣:</h2></li>
<ul>
<li>玩minecraft</li>
<li>打code</li>
<li>影片剪輯</li>
<li>打爵士鼓</li>
</ul>
</ul>
</div>
<hr>
<div id="top-songs">
<h1>我的前三歌曲:</h1>
<ol>
<li><a href="https://www.youtube.com/watch?v=PuMz4v5PYKc">Porter Robinson - Look at the Sky</a></li>
<li><a href="https://www.youtube.com/watch?v=FnhedPLxksQ">Kessoku band - UNITE</a></li>
<li><a href="https://www.youtube.com/watch?v=UEwjYcGe0WU">Kessoku band - Doppelganger</a></li>
</ol>
</div>
</div>
</body>
</html>body {
background-image: url("./images/wallpaper.png");
background-repeat: no-repeat;
background-size: cover;
}
.whole {
background-color: rgba(255, 255, 224, 0.8);
width: 30vw;
}
#top {
border-style: solid;
border-width: 5px;
border-radius: 10px;
border-color: tomato;
width: 20vw;
text-align: center;
}
#interests {
border-style: dotted;
border-width: 5px;
border-radius: 10px;
width: 20vw;
}
#top-songs {
border-style: dashed;
border-width: 5px;
border-radius: 10px;
width: 20vw;
}用我們目前交的東西,來幫我們的網站加個美編
ex: 背景圖片,邊框,背景顏色等
Box Model
margin
padding
margin: 100px;margin-top: 100px;
margin-bottom: 100px;
margin-left: 0px;
margin-right: 50px;我們這裡有一個沒有margin的網站:
我給上面的div:
margin-bottom: 100px;就會變這樣:
100px 的 margin ->
(我就延續上次的範例)
body {
background-image: url("./images/wallpaper.png");
background-repeat: no-repeat;
background-size: cover;
}
.whole {
background-color: rgba(255, 255, 224, 0.8);
width: 30vw;
margin-top: 50px;
margin-left: 35vw;
}
#top {
border-style: solid;
border-width: 5px;
border-radius: 10px;
border-color: tomato;
width: 20vw;
text-align: center;
margin-left: 7em;
margin-bottom: 50px;
}
#interests {
border-style: dotted;
border-width: 5px;
border-radius: 10px;
width: 20vw;
margin-left: 7em;
margin-bottom: 25px;
}
#top-songs {
border-style: dashed;
border-width: 5px;
border-radius: 10px;
width: 20vw;
margin-left: 7em;
margin-top: 25px;
}padding: 100px;padding-top: 100px;
padding-bottom: 100px;
padding-left: 0px;
padding-right: 50px;我們這裡有一個沒有padding的div:
我給div:
padding: 100px;就會變這樣:
100px 的 padding ->
margin 和 padding 是很神奇的東西 (我自己也搞不太懂),
大部分的時間都是慢慢摸索,看那些數字可以用出最好的排版
我們學完padding, margin, border之後
這些東西和起來就叫做box model,給個圖看看:
(我就延續上次的範例)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>網頁班</title>
<link href="./styles.css" rel="stylesheet">
</head>
<body>
<div class="whole">
<div id="top">
<h1>翁釩予</h1>
<h2>MLGnotCOOL</h2>
<br>
<img src="./images/pfp_bgremoved.png" width="100px">
</div>
<br>
<div id="interests">
<ul>
<li><h2>我的興趣:</h2></li>
<ul>
<li>玩minecraft</li>
<li>打code</li>
<li>影片剪輯</li>
<li>打爵士鼓</li>
</ul>
</ul>
</div>
<hr>
<div id="top-songs">
<h1>我的前三歌曲:</h1>
<ol>
<li><a href="https://www.youtube.com/watch?v=PuMz4v5PYKc">Porter Robinson - Look at the Sky</a></li>
<li><a href="https://www.youtube.com/watch?v=FnhedPLxksQ">Kessoku band - UNITE</a></li>
<li><a href="https://www.youtube.com/watch?v=UEwjYcGe0WU">Kessoku band - Doppelganger</a></li>
</ol>
</div>
</div>
</body>
</html>body {
background-image: url("./images/wallpaper.png");
background-repeat: no-repeat;
background-size: cover;
}
.whole {
background-color: rgba(255, 255, 224, 0.8);
width: 30vw;
margin-top: 50px;
margin-left: 35vw;
padding: 25px;
}
#top {
border-style: solid;
border-width: 5px;
border-radius: 10px;
border-color: tomato;
width: 20vw;
text-align: center;
margin-left: 7em;
margin-bottom: 50px;
padding: 5px;
}
#interests {
border-style: dotted;
border-width: 5px;
border-radius: 10px;
width: 20vw;
margin-left: 7em;
margin-bottom: 25px;
padding: 5px;
}
#top-songs {
border-style: dashed;
border-width: 5px;
border-radius: 10px;
width: 20vw;
margin-left: 7em;
margin-top: 25px;
margin-bottom: 50px;
padding: 5px;
padding-left: 20px;
}(我就延續上次的範例)
body {
background-image: url("./images/wallpaper.png");
background-repeat: no-repeat;
background-size: cover;
}
.whole {
background-color: rgba(255, 255, 224, 0.8);
width: 30vw;
margin-top: 50px;
margin-left: 35vw;
padding: 25px;
}
#top {
border-style: solid;
border-width: 5px;
border-radius: 10px;
border-color: tomato;
width: 20vw;
text-align: center;
margin-left: 7em;
margin-bottom: 50px;
padding: 5px;
}
#interests {
border-style: dotted;
border-width: 5px;
border-radius: 10px;
width: 20vw;
margin-left: 7em;
margin-bottom: 25px;
padding: 5px;
}
#top-songs {
border-style: dashed;
border-width: 5px;
border-radius: 10px;
width: 20vw;
margin-left: 7em;
margin-top: 25px;
margin-bottom: 50px;
padding: 5px;
padding-left: 20px;
}position
display
偽類
position: static;
position: relative;
position: absolute;
position: fixed;
position: sticky;div {
position: static;
}原本css的預設值
就是和沒改一樣
div {
position: relative;
left: 30px;
top: 50px;
}會和它原本的位置有相對的移動
可以由 top, bottom, left, right 去移動
移動不會影響其他元素
將div往原本的位置移動
left 30px
top 50px
div {
position: absolute;
top: 50%;
left: 50%;
}會是在網頁中的絕對位置
不會受原本的位置影響
可以由 top, bottom, left, right 去移動
移動不會影響其他元素
將div置中
div {
position: fixed;
bottom: 0;
right: 0;
}會在網頁的某個固定位置
放大縮小 滑動都不會影響它的位置
可以由 top, bottom, left, right 去移動
將div固定在右下角
div {
position: sticky;
}有時候是absolute,有時候是fixed
看有沒有要超出視窗決定
如果在視窗內,他會正常的顯示
如過要離開視窗時,會"黏"在視窗的邊框
https://www.w3schools.com/css/css_positioning.asp
然後可以自己玩玩看position
display: inline;
display: block;
display: inline-block;inline, block, inline-block
div {
display: inline;
}div {
display: block;
}div {
display: inline-block;
}.以inline的方式呈現,但同時擁有block的屬性
.可設定元素的寬高/margin/padding
.可水平排列
pseudo-classes
我們最常用的只有一個 :hover
(可以去查查看有沒有其他的 我其實不知道)
#div1:hover{
}當我們滑鼠放到div上的時候,會改變這div的css
pseudo-classes
#div1 {
background-color: lightyellow;
width: 300px;
height: 300px;
padding: 100px;
margin: 100px;
transition: 0.3s;
}
#div1:hover{
background-color: lightblue;
transition: 0.3s;
scale: 1.2;
}可以給他transition時間 (轉場時間)
scale是改變他的大小
我們CSS講完了!
大致上可以做出一個有美編的簡單網站了
剩下時間就給你們複習吧!
這裡是我只用HTML, CSS做出的自我介紹網站:
JS介紹
JS 基礎語法
<body>
<script src="./main.js"></script>
</body>這是檔案路徑 應該不用我再講一次了吧 :P
alert("Hello World!");console.log("Hello World!");就會發現有我們剛剛那個打的東西
(console.log() 有點像python的print)
console.log("Hello World!");1 - Number 數字
顧名思義,是存數字的
可以存很多種數字,如整數、小數等
2 - String 字串
是存文字的,要用 " "或 ' ' 包起來
如:"Hello", ':P'
3 - Boolean 布林值
true / false
真 / 假
請問以下會分別輸出什麼:
console.log(11 + 22);
console.log("11" + "22");答案:
33 和 "1122"
因為上面是數字,下面是字串
console.log(2+3); //5
console.log(3-2); //1
console.log(3*2); //6
console.log(5/2); //2.5
console.log(5%2); //1
console.log(5**2); //25把答案console.log出來!
let/var/const 自訂的變數名稱 = 值;
let x = 5;
var x = 5;
const x = 5;var
比較舊
不建議使用
let
可以取代 var
通常99%都用這個
const
常數 不能被改變
在程式碼裡面是不能被改變的變數
var x = 5;const x = 5;let x = 5;var x = 5;意思不是數學的 等於
是 賦值
意義:賦予x一個值為5
if 顧名思義 就是可以判斷一格東西是否為真
語法:
let x = 5;
if (x < 5){
console.log("x is smaller than 5");
}else if (x == 5){
console.log("x is equal to 5");
}else{
console.log("x is greater than 5");
}會一個一個比下去,如果符合的話就會執行裡面的東西
else if 可以一直接,不一定只有一個,也可能沒有
也可以沒有 else
for 可以對一段程式重複執行
語法:
for (let i=0; i<4; i++){
console.log(i);
}預設; 要符合的條件; 每次回圈要執行的東西
補充:
i++ -> i=i+1
i += 2 -> i=i+2
試試看if和for迴圈!
let arr = [1, 5, 6, 8, 5];
let ans = 0;
for (let i = 0; i < 5; ++i){
if (arr[i] > ans){
ans = arr[i];
}
}
console.log(ans);on click
function
getElementById()
getElementsByClassName()
<button>
(顧名思義就是一個按鈕)
<button>
<div><h1>Hello</h1></div>
</button>那我們的button可以作什麼呢
可以連到我們的JS去做事情
<button onclick="click_btn()">
<div><h1>Hello</h1></div>
</button>onclick -> 按下時
"...()" 裡面的東西 -> 一個function 等一下介紹
當我們按下這個按鈕時,會跑一個叫"click_btn"的function
function
函式(有點像數學的那個)
呼叫的時侯可以執行一段程式碼
function idk(){
//function
alert("Hello World");
}
idk(); //calls the funcionfunction
合併我們剛剛學的東西
我們按下button時可以在JS執行一段程式
<button onclick="click_btn()">
<div><h1>Hello</h1></div>
</button>function click_btn(){
alert("Hello World");
}小(沒有用)的補充:
prompt:讓使用者在alert時可以輸入東西
function click_btn(){
const input = prompt("your name?");
alert(input);
}getElementById()
getElementsByClassName()
可以從 id 或 class 取得我們要的物件
<div id="div1">
<h1 class="text">Hello</h1>
</div>const div1 = document.getElementById("div1");
const text = document.getElementsByClassName("text");getElementById()
getElementsByClassName()
那我們可以對這些東西作甚麼呢?
const text = document.getElementById("text");
text.style.color="red";(前面學到的都可以)
"元素".style."css要改的" = "要改成的值"
getElementById()
getElementsByClassName()
那我們可以對這些東西作甚麼呢?
const text = document.getElementById("text");
text.style.display = "none";ex: 隱藏東西
ex: 按下時隱藏和顯示div
<body>
<div id="div1">
<h1>Hello</h1>
</div>
<button onclick="toggle_div()">toggles div</button>
<script src="./main.js"></script>
</body>function toggle_div(){
const div1 = document.getElementById("div1");
if (div1.style.display == "none"){
div1.style.display = "block";
}else{
div1.style.display = "none";
}
}ex: 按下時改變顏色 (補充input)
<body>
<div>
<h1 id="text">Hello</h1>
</div>
input color for the text: <input id="text_color"> <br><br>
<button onclick="change_color()">change the color!</button>
<script src="./main.js"></script>
</body>function change_color(){
const input = document.getElementById("text_color").value;
const text = document.getElementById("text");
text.style.color = input;
}
正確的話要顯示正確
錯誤的話要顯示錯誤
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="./style.css" rel="stylesheet">
</head>
<body>
<h1 id="correct_text">Correct!</h1>
<h1 id="incorrect_text">Incorrect!</h1>
input secret word: <input id="secret"> <br><br>
<button onclick="sumbit()">sumbit!</button>
<script src="./main.js"></script>
</body>
</html>#correct_text{
color: greenyellow;
display: none;
}
#incorrect_text{
color: tomato;
display: none;
}const password = "asdfjkl;";
function sumbit(){
const passcode = document.getElementById("secret").value;
if (passcode == password){
document.getElementById("correct_text").style.display = "block";
document.getElementById("incorrect_text").style.display = "none";
}else{
document.getElementById("correct_text").style.display = "none";
document.getElementById("incorrect_text").style.display = "block";
}
}先自己打打看一遍
可以複製貼上玩看看
(其實還有很多我沒講 尤其是js的其他framework
有興趣可以自己去看看 jquery, react, vue 之類的東西,我在這裡就不講了)
push
pull
clone
commit
git是一個分散式版本控制軟體,最初由林納斯·托瓦茲創作,於2005年以GPL授權條款釋出。最初目的是為了更好地管理Linux核心開發而設計。
const p = [1, 2, 3, 4, 5];
console.log(p[0]);
//initial commit假設我們commit了一個新東西
const p = [1, 2, 3, 4, 5];
console.log(p[1]);
alert("Hello!");
//commit #2我們可以新增或刪除東西
並且作一個新的commit
const p = [1, 2, 3, 4, 5];
for (int i=1; i<=4; i++){
console.log(p[i]);
}
//commit #3const p = [1, 2, 3, 4, 5];
console.log(p[0]);
//initial commit也可以回去之前的commit
me when job
先幫我註冊一個帳號,以後寫專案都可以用到
(當你會講這些的時後別人就會覺得你很強)
| 名詞 | 解釋 |
|---|---|
| commit | 提交一個版本的程式 |
| clone | 從遠端複製一份程式到本地 |
| pull | 將遠端的程式更新到本地 |
| push | 將本地的更新送到遠端 |
| fetch | 跟pull差不多 但只會下載不更新 |
| revert | 取消commit的內容 |
(當你會講這些的時後別人就會覺得你很強)
| 名稱 | 用途 |
|---|---|
| merge | 將兩個不同人的commit合併 |
| branch | 讓兩個不同目的的程式分開 |
| fork | 將別人的程式複製一份變自己的(用於contribute) |
| pull request | 將自己做好的內容請求合併 |
那我們怎麼使用呢?
github desktop
版本管理很方便
vscode 內建的
使用非常簡單
(主要介紹這個)
vscode + github
先在左邊按 "New" 創一個新的repo
vscode + github
填入你repo的名稱(下面的可以先不管)
vscode + github
vscode + github
接下來要把這個repo clone到你的vscode
新的repo
已經有commit的repo
vscode + github
接下來要把這個repo clone到你的vscode
在vscode按下 "ctrl + shift + p"
打入git clone 然後按下enter
選擇你資料夾要在的位置
vscode + github
接下來要在vscode設定你的github帳號
在你的terminal打入這兩的指令
git config --global user.name "您的姓名"
git config --global user.email "您的Email"
vscode + github
在準備好你的第一個commit之後
打入你的commit名稱 並且按下綠色按鈕
在登入之後就成功的push到github了!
vscode + github
成功在github上看到你的commit了!
github
我們通常會在repo加一些特定檔案:
README.md
加入底下可以說明的東西
(格式是markdown如果想學可以自己去看看)
.gitignore
push時github會忽略的東西
常用於不能公開的東西 像是token之類的
用github架靜態網頁
github 架靜態網站
github 有一個非常好用的功能
就是可以免費架靜態網站
記得 html檔案要取名成 "index.html"
github
github
github
把Branch設成你要用的 (預設是main)
並且按下 Save
github
每次commit之後 就會自動更新網站了
通常更新要幾分鐘
連結一樣在pages那
pull
push時遇到conflict
現在電腦1有我們原本的檔案 並且把他push到github了
commit #1
commit #1
我們現在要在電腦2修改這個repo
首先當然要先把他clone下來 (上禮拜有教)
git clone
commit #1
commit #1
commit #1
我們把電腦二的新版本push到github
git push
commit #1
commit #2
commit #2
我們現在在電腦一更新我們的檔案 試著push到github
commit #2-2
(從commit #1修改的)
commit #2
commit #2
git push
但我們就遇到了一個問題!
就是github現在的兩個commit有衝突 導致我們現在沒辦法成功的push
最簡單的方法 (如果你自己個人作小專案的話)
就是在每次要對版本作更新前,先將最新的版本 git pull下來
(關於pull是什麼 上禮拜講過了 流程和clone差不多 只是要選pull就好了)
你也可以用terminal直接 git push --force,直接把原本的commit覆蓋掉,但不太建議這樣作
也可以用vscode幫你顯示哪裡有conflict,一個一個去解決
(遇到的時候都可以查google,我就不多加解釋了)
我們也可以創一個新的Branch
關於Branch是什麼呢?影片
如果我下禮拜有時間的話,我就多補充
因為當比較多人要在同個repo上工作,才會用到Branch, merge, rebase等功能
個人的project不太會用到