Open Lu-yeom opened 3 years ago
課程筆記:
一、網頁其實是文字檔,其內容是瀏覽器可以讀懂的結構。
二、絕對會用到的標籤:html、head 與 body
<!DOCTYPE HTML>
、<html>
、<head>
、<body>
<head>
(開)</head>
(合)
<!DOCTYPE HTML>
三、HTML最早最常見的用途為「顯示文章」,標籤如下:
* ```<h1>```→heading標題,有1~6的分別,代表字體的大小,數字越大字體越小
* ```<p>```→paragraph段落,可呈現文章(可利用Loren ipsum網頁上的文章來測試字型和字體的呈現)
<!DOCTYPE HTML>
介紹
四、很常見的標籤:div 與 span
* ```<div>```→division,分組,在網頁上不會有視覺上的變化,但是可以把一個區塊包起來變成一組,對於要上色、造型都很方便
<!DOCTYPE HTML>
介紹
* ```<span>```也是分組,可以單獨針對一個字做變化
* 顯示圖片就靠它:img
* img的結構→```<img src=”圖片網址” />``` (src是source來源)
* 也可以幫圖片作註解→```<img title=”名稱” src=”圖片網址” />```
* 如果圖片無法顯示,也可以用文字替代→```<img alt=”I am image” title=”名稱” src=”圖片網址” />```
六、顯示清單:ul、ol 與 li
* ```<ul>```→unorderd list
* ```<ol>```→ordered list
* ```<li>```→list item
<!DOCTYPE HTML>
介紹
如果改成:
六、保留完整格式:pre
* ```<pre>```→preformatted text,例如程式碼會有換行、空格,用```<pre></pre>```框起來就可以原封不動地顯示出來
* ```<br>```→line break換行,在要換行的段落後方加上```<br>```(或```<br />```)
七、表格必備標籤:table、th、tr 與 td
* ```<table>```→表格
* ```<tr>```→table row橫向的列
* ```<td>```→table cell表格的值
* ```<th>```→table header可將表格標題加強顯示
姓名 | //改成會變成粗體的標題,可更清楚表示 | 國文分數 | 英文分數 |
---|---|---|---|
小明 | 70 | 90 |
八、```<a>```→anchor錨點,可連結到網頁內或外的位置
* href→hypertext reference
* 如果要設定是當前視窗跳至其他網頁:
```<a href="網址" target=’_self’>take me to google</a>```
* 如果要設定是開其他分頁:
```<a href="網址" target=’_blank’>take me to google</a>```
* 也可以在頁面間跳轉:
九、語意化的 UI 標籤:main、nav、footer 等等
* ```<main>```
* ```<nav>```navigator導覽列
* ```<footer>```
十、直接用別人的網頁:iframe
課程筆記:
一、表單相關標籤:form、input、textarea
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>I am title</title>
</head>
<body>
<form>
<div>
姓名<input type="text" /> //會呈現輸入框
</div>
<div>
密碼<input type="password" /> //會將輸入內容屏蔽
</div>
<div>
Email<input type="email" /> //會自動驗證輸入內容是否符合email格式
</div>
<div>
日期<input type="date" /> //會呈現日期年月日
</div>
<div>
性別<input type="radio" name=”gender” id=”male” /><label for=”male”>男性</label>
<input type="radio" name=”gender” id=”female” /><label for=”female”>女性</label>
<input type="radio" name=”gender” id=”other” /><label for=”other”>其他</label>
<-- !--> 會出現單選框,而且點文字就可以選取
</div>
<div>
興趣<input type="checkbox" id=”sports” /><label for=”sports”>運動</label>
<input type="checkbox" id=”reading” /><label for=”reading”>閱讀</label>
<input type="radio" name=”gender” id=”other” /><label for=”other”>其他</label>
<-- !--> 會出現複選框,而且點文字就可以選取
</div>
<div>
<imput type="submit" value=”送出表單” /> //輸入框後會呈現提交按鈕
</div>
</form>
</body>
</html>
二、SEO 與相關標籤:meta tag
<meta>
→keywords, description, og三、Escape:該怎麼顯示標籤?
&
<
>
→ >
<div></div>
標籤 => <div></div>
四、CSS 基礎 Part1:Selector
<body></body>
<!DOCTYPE HTML>
例:放在```<head></head>```
<!DOCTYPE HTML>
最佳解:開style.css檔案將```<style></style>```內的內容存入,再連結
<!DOCTYPE HTML>
五、CSS selector:universal selectors 可選取所有```<body></body>```的元素
在style.css中顯示如下:
{ color:red; }
六、CSS Selector:標籤
可以同時設定標籤```<div></div>```和```<body></body>```的css樣式
div { background: red; }
body { background: blue; }
七、CSS Selector:id 與 class
* 指定標籤的樣式```<div id=”div1”>hello</div>```
在style.css中
background: red; }
* 指定class的樣式```<div class=”bg-yellow text-white” >hello</div>```
.bg-yellow { background: yellow; } .text-white { color: white; }
八、CSS Selector:同時符合
<div class=”bg-yellow bg-real-yellow” >hello</div>
div.bg-yellow.bg-real-yellow { //把條件同時寫在一起,就會同時都符合
background: yellow;
}
九、CSS Selector:底下的元素
<html>
<head>
<meta charset= "utf-8"/>
<title>I am title</title>
<link rel="stylesheet" herf="./style.css">
</head>
<body>
<div class="Lv1">Lv1
<div>Lv2
<div>L3</div>
</div>
</div>
</body>
</html>
.lv1 {
background: red;
}
.lv1 > div {
background: red;
}
.lv1 > div > div {
background: red;
}
.lv1 div {
background: red;
}
今日心得:今天進入到CSS切版的內容,一下子就塞了一堆東西進來,真的不容易記住啊...難怪Huli會說很複雜。感覺上在寫網頁的時候,就要一直測試做出來的效果呢。
課程筆記:
一、CSS Selector:~ 與 + (選擇旁邊的,必須要在同一階層下)
<html>
<head>
<meta charset="utf-8" />
<title>I am title</title>
<style>
<link rel="stylesheet" href="./style.css" />
</style>
</head>
<body>
<div class="bg-red">div1</div>
<div>div2</div>
<div class="bg-red">div3</div>
<div class="bg-red">div4</div>
<div>123</div>
<span>456</span>
<span>3333</span>
</body>
</html>
【style.css模式】
.bg-red + .bg-red { // +只能選擇旁邊一個元素
background: red;
}
div ~ span {
background: blue; // ~可以選擇旁邊以後的元素
}
通常是在設定list的間距時,若不要動到最左邊的元素,就可以用+或~
<body>
<span class="bg-red">span1</span>
<span class="bg-red">span2</span>
<span class="bg-red">span3</span>
<span class="bg-red">span4</span>
</body>
【style.css模式】
.bg-red ~ .bg-red {
margin-left: 20px;
}
二、CSS Selector:Pseudo-classes,以 hover 為例
span:hover {
background: red; //滑鼠移動過去會把該區塊的背景變成紅色
}
三、CSS Selector:nth-child
<html>
<head>
<meta charset="utf-8" />
<title>I am title</title>
<style>
<link rel="stylesheet" href="./style.css" />
</style>
</head>
<body>
<div class="wrapper">
<div>row1</div>
<div>row2</div>
<div>row3</div>
<div>row4</div>
<div>row5</div>
</div>
</body>
</html>
【style.css模式】
.wrapper div:first-child {
background: red;
}
四、CSS Selector:before 與 after
<html>
<head>
<meta charset="utf-8" />
<title>I am title</title>
<style>
<link rel="stylesheet" href="./style.css" />
</style>
</head>
<body>
<div class="wrapper">
hello
</div>
</body>
</html>
【style.css模式】
.wrapper::before { //或是after
content: “123”;
}
可以直接更改css作用在html,而不是去更改html,較常見是可以指定某個class都出現同一個元素或是同一種顏色
五、CSS Selector 的權重
今日心得:今天來不及看完,明天要趕進度...!
課程筆記:
一、背景:background
<html>
<head>
<meta charset="utf-8" />
<title>I am title</title>
<style>
<link rel="stylesheet" href="./style.css" />
</style>
</head>
<body>
<div id=”box1”>box</div>
<div id=”box2”>box</div>
</body>
</html>
【style.css模式】
#box1 {
background: red; //顏色設定也可以用rgb、rgba
}
#box2 {
background: green;
}
也可以把背景設成圖片
#box1 {
background: url("圖片位置"); // 如果放在同資料夾下,可輸入./圖片名.jpg
height: 500px; //可控制圖片高度
width: 2000px; //可控制圖片寬度
}
若超出圖片寬度會重複,可加註background: url("圖片位置") no-repeat;
或是調整圖片位置background: url("圖片位置") no-repeat center center;
center也可替換成top、bottom、left、right
調整圖片大小:
#box1 {
background: url("圖片位置");
background-size: 100px 100px; //也可替換成百分比100%、50%、contain(不管視窗大小不會調動比例)、cover(會隨比例縮放)
}
二、把自己框起來:border 與 border-radius
#box1 {
background: red;
border: 2px solid green;
boder-style: dashed; //有很多類型
}
#box1 {
background: red;
width: 100px;
hright: 100px;
boder-radius: 4px; //邊框的角會內縮,如50px會變成圓形
}
也可做成相框的感覺:(顯示會像梯形)
#box1 {
background: red;
width: 100px;
hright: 100px;
boder-top: 10px solid green;
boder-bottom: 10px solid yellow;
boder-left: 10px solid pink;
boder-right: 10px solid blue;
}
用css畫三角形:
#box1 {
background: transparent;
width: 100px;
hright: 100px;
boder-top: 10px solid green;
boder-bottom: 10px solid transparent;
boder-left: 10px solid transparent;
boder-right: 10px solid transparent;
}
三、邊距margin 與 padding
#box1 {
background: orange;
width: 100px;
height: 100px;
padding: 10px; //預設為上下左右一起調整,也可寫成10px 20px 20px 40px分別設定
}
#box2 {
background: green;
width: 100px;
height: 100px;
margin: 20px; //不會影響寬高,會影響框線外的邊界
}
另外很多瀏覽器會預設邊界,所以可以先設定
body {
margin: 0;
}
四、文字相關:color、font-family、font-weight 與 line-height
#box1 {
background: orange;
height: 100px;
font-size: 30px; //字體大小
font-weight: bold; //字體粗細,或是可寫成300(細)、700(粗)
font-family: “字型名稱”;
letter-spacing: 1px; //調整字距
line-height: 1.5em;
text-align: center; //水平對齊,垂直對齊靠line-height控制
}
五、文字相關 part2:word-break 與 white-space
若文字超出邊框,可設定word-break: break-all
(直接切斷)或break-word
(依照字詞切斷)
若不要斷行,可設定white-space: nowrap
六、overflow 與 text-overflow
#box1 {
background: orange;
height: 100px;
font-size: 30px;
font-weight: bold;
text-align: center;
white-space: nowrap;
overflow: scroll; //不換行,但長度超過邊框的話會出現滾動式橫軸
text-overflow: ellipsis; //文字超出長度會省略,但前提是overflow: hidden
}
七、加了我質感瞬間升級:transition
#box1 {
background: orange;
widtht: 200px;
height: 100px;
transition: all 1s; //滑鼠移至目標會有漸變效果
}
#box1:hover {
background: green;
color: white;
}
高級版:
#box1 {
widtht: 200px;
height: 100px;
border-radius: 30px;
text-align: center;
line-height: 100px;
transition: all 1s ease-in; //漸變動畫可另外設定
color: black;
border: 5px solid orange;
transition: all 03.s ease-in;
}
#box1:hover {
background: orange;
color: white;
cursor: pointer; //鼠標移至目標會變成其他圖案
}
八、Die Verwandlung:transform 的妙用
#box1 {
widtht: 200px;
height: 100px;
border-radius: 30px;
text-align: center;
line-height: 100px;
color: white;
background: orange;
transition: all 03.s;
}
#box1:hover {
transform: scale(2) //滑鼠移至目標會變成2倍大
}
使用transform效果:
#box1 {
position: absolute;
widtht: 200px;
height: 100px;
border-radius: 30px;
text-align: center;
line-height: 100px;
color: white;
background: orange;
top: 50%;
left: 50%;
transform: translate(-50%, -50%)
}
今日心得:今天的課程是css各種花式(?)功能,原來可以做到那麼多效果,不過相對的也是要有一點想像力和實驗精神,才能做出與眾不同的網頁。
課程筆記:
一、什麼是盒模型?
二、display 的三種形式:block、inline 與 inline-block
<html>
<head>
<meta charset="utf-8" />
<title>I am title</title>
<style>
<link rel="stylesheet" href="./style.css" />
</style>
</head>
<body>
<div id=”box”>box1</div>
<div id=”box”>box2</div>
<div id=”box”>box3</div>
</body>
</html>
以上為最基本的block,div
、h1
、p
...調什麼都可以,但是一個block就算設定沒有占滿畫面,仍然是預設整個block,所以不會發生其他block遞補到空白處的情形。
<html>
<head>
<meta charset="utf-8" />
<title>I am title</title>
<style>
<link rel="stylesheet" href="./style.css" />
</style>
</head>
<body>
<span id=”box”>box1</span>
<span id=”box”>box2</span>
<span id=”box”>box3</span>
</body>
</html>
以上為inline,代表為span
、a
,無法調元素的寬高和上下邊距,因為寬高會依據元素內容來顯示(可以設定 margin 跟 padding,但只能設定左右不能設定上下)。
inline-block:結合block和inline的優點,不會自動換行,可並排,可設定元素寬高。
三、static 與 relative
body {
margin: 0;
}
.box {
background: orange;
width: 100px;
height: 100px;
margin: 10px;
}
.box:nth-child(2) { position: relative; top: -20px; left: 30px; }
四、沒那麼難理解的 absolute 與 fixed
.box { background: orange; width: 300px; height: 100px; margin: 10px; display: block; }
.box:first-child { position: fixed; width: 100px; background: red; bottom: 100px; right: 0px; }
* fixed會將元素固定定位在指定處,無論視窗怎麼滑動都不會更動。
* absolute : 會跳脫 normal flow ,不會佔到空間,元素會重疊,可設定 left 、top等來偏移元素。
五、決定圖層順序:z-index
.box { background: orange; width: 300px; height: 100px; margin: 10px; display: block; position: relative; }
.box:nth-child(2) { background: red; top: 40px; z-index: 2; }
圖層預設數字越大位置越靠前,如果想蓋過圖層就要設定數字比它大。
六、position: sticky
body { margin: 0; } .box { background: orange; width: 100px; height: 100px; margin: 10px; display: block; position: relative; }
.box:nth-child(2) { background: red; top: 0px; position: sticky; z-index: 2; }
類似word的凍結窗格功能,當視窗滑動到指定位置後元素就會黏住不動。
---
今日心得:嗯...又出現了很多功能,努力記憶吧...
日期:110年5月17日(星期一) 今日進度:無
課程筆記:無
今日心得:下班回來要看課程時很衰的遇到停電...沒辦法好好跟課...明天要多趕一點進度了。