CSS(Cascading Style Sheets) 階層式樣式表
 
基本 CSS 命名 1 2 3 4 5 6 7 8 wrap 時間軸 timeline 條幅廣告 banner menu 人頭 avatar sidebar 麵包屑 path/crumb navbar 
 
CSS 三種使用方法 1 2 3 4 5 .evening  {	background : orange; } 
 
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 <!DOCTYPE html > <html  lang ="en" > <head > 	<meta  charset ="UTF-8" >  	<meta  name ="viewport"  content ="width=device-width, initial-scale=1.0" >  	<meta  http-equiv ="X-UA-Compatible"  content ="ie=edge" >  	<title > Document</title >  	 	<link  rel ="stylesheet"  href ="style.css" >  	 	<style >  		.noon { 			background : yellow; 		} 	</style >  </head > <body > 	 	<div  style ="background:red" > Good morning</div >  	 	<div  class ="noon" > Good afternoon</div >  	 	<div  class ="evening" > Good evening</div >  </body > </html > 
 
simple css init 1 2 3 4 5 6 7 8 9 10 11 12 .debug  *, .debug  {	outline : 1px  solid gold } html  {	font-size : 12px ; } html , body , h1  ,h2  ,h3  ,h4  ,h5  ,h6  ,p  {	padding : 0 ; 	margin : 0 ; } 
 
CSS naming BEM(Block Element Modifier) 
1 2 3 4 5 6 7 8 9 <div  className ="nav" >     <nav  className ="nav__container" >        <ul  className ="nav__list" >          <li  className ="navList__item--blue" > I am blue!</li >          <li  className ="navList__item--red" > I am red!</li >          <li  className ="navList__item--hover" > I have a hover state!</li >        </ul >      </nav >  </div > 
 
單位 1 2 3 4 5 6 7 8 9 10 11 12 .box  {	  	height : 50px ; 	  	padding : 0.75rem  1.5rem ; 	  	line-height : 1.5rem ; 	  	width :50% ; 	  	height : 100vh ; } 
 
優化 
資源
Minify : CSS壓縮 
gzip* : 檔案壓縮 
 
 
載入方式
CSS Sprites : 小圖合併 
Critical CSS : 重要 CSS 先 load 
Cache* : server 設定 
 
 
執行方式
 
 
CSS Selector 選擇器 種類 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 * { 	background : yellow; } div  {	color : red; } .evening  {	background : orange; } #no1  {	background : blue; } input [type=checkbox] :checked  ~ label  {  text-decoration : line-through;   color : rgba (0 ,0 ,0 ,0.3 ); } .todo :hover  .btn-delete  {  opacity : 1 ; } 
 
Multiple Selector 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 div .group1  {	background : orange; } div .wrap  > div  {	background : pink; } div .wrap  div  {	background : blue; } .line2  + div {	background : red; } .line2  ~ div {	background : red; } 
 
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 span  {	background : orange; } span :hover  {	background : blue; } div  span :first -child {	background : red; } div  span :not (:first -child) {	background : red; } div  span :last-child  {	background : green; } div  span :nth-child (3 ) {	background : blue; } div  span :nth-child (odd) {	background : red; } div  span :nth-child (even) {	background : blue; } div  span :nth-child (3 n) {	background : blue; } div  span :nth-child (3 n+1 ) {	background : blue; } 
 
Pseudo elements 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 .wrap  > div ::before  {	content : "$" ; } .wrap  > div ::after  {	content : "NTD" ; 	color : red; } .wrap2  > div ::before  {	content : attr (class) ; } .wrap2  > div ::after  {	content : attr (data-id); } 
 
1 2 3 4 5 6 7 <div  class ="wrap" > 	<div > 1000</div >  </div > <div  class ="wrap2" > 	<div  class ="group"  data-id ="NTD" > 100</div >  	<div  class ="group"  data-id ="RMB" > 200</div >  </div > 
 
CSS 權重 1 2 3 4 5 6 7 8 9 10 11 12 <style > 	.group1 { 		background : blue !important ; 	} </style > <div > 	<span > Span1</span >  	<span  class ="group1"  style ="background:green;" > Span2</span >  	<span > Span3</span >  </div > 
 
CSS Properties 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 <style > .box1 { 	background : url (./images.jpg ) no-repeat center center; 	/* no-repeat, repeat 		 left , right , center  		 top , bottom , center */ 	background-size : cover; 	/* 50% 50% 		 cover 		 auto  		 contain ... */ 	height : 300px ; } .box2 { 	/* background: pink; 	background : #ffff00 ; 	background : rgb (200 ,150 , 20 ); */ 	 	background : rgba (200 ,150 , 20 ,0.3 ); } .box3 { 	height : 100vh ; 	background : url ("images/header-img.jpeg" ) no-repeat center center /cover; } </style > <body > 	<div  class ="box1" > Box1</div >  	<div  class ="box2" > Box2</div >  </body > 
 
漸層有以下幾種 : 
linear-gradient:線性漸層 
radial-gradient:放射漸層 
conic-gradient:圓錐形漸層(較新) 
repeating-radial-gradient:放射重複漸層 
repeating-linear-gradient:線性重複漸層 
repeating-conic-gradient:圓錐形重複漸層(較新) 
 
可以套用漸層的 CSS 屬性有兩種 :
background:元素的背景 
list-style-image:清單預設的符號圖案 
 
如果沒有設定角度,預設從上往下 進行漸層 
background:linear-gradient(方向, 顏色1 位置, 顏色2 位置); 
 
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 <!DOCTYPE html > <html  lang ="en" > <head > 	<meta  charset ="UTF-8" >  	<meta  name ="viewport"  content ="width=device-width, initial-scale=1.0" >  	<meta  http-equiv ="X-UA-Compatible"  content ="ie=edge" >  	<title > Document</title >  	<style >  		.box { 			width : 80% ; 			height : 80vh ; 			border : 1px  solid #000 ; 			margin : 0  auto; 			 			 			 			 			 			background : linear-gradient (135deg , red, yellow); 			 			 		} 	</style >  </head > <body > 	<div  class ="box" > </div >  </body > </html 
 
border, border-radius and outline 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 <style > .box { 	background : orange; 	 	 	 	 	height : 200px ; 	width : 200px ; 	 	 	border-radius : 50%  50% ; 	 	/* height: 0px; 	width : 0px ; 	border-top : 100px  solid red; 	border-right : 100px  solid transparent; 	border-bottom : 100px  solid transparent; 	border-left : 100px  solid transparent; */ } </style > <body > 	<div  class ="box" > Box</div >  </body > 
 
文字相關 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 <style > .box {	 	color : red; 	font-size : 24px ; 	font-weight : bold; 	font-family : "新細明體" ; 	 	letter-spacing : 1px ; 	 	line-height : 1.5em ; 	 	text-align : center; 	width : 400px ; 	 	 	white-space : nowrap; 	overflow : hidden; 	 	text-overflow : ellipsis; 	/* text-decoration: 文字特效  		none 					預設值,無額外文字特效 		overline			文字增加上線特效 		underline			文字增加底線特效 		line-through	文字增加刪除線特效 	*/ 	text-decoration :underline; } </style > <body > 	<div  class ="box" > Lorem ipsum dolor sit amet consectetur adipisicing elit. Sed debitis eius minima ab earum autem nihil tempore nobis provident maxime! Repellat eligendi facere quod dolore voluptatibus nulla, voluptatem corporis error?</div >  </body > 
 
1 2 3 4 5 6 7 8 9 10 box { 	 	line-height : 3.5 ; 	 	line-height : 3em ; 	 	line-height : 34% ; 	 	line-height : 32px ; } 
 
text-align 文字水平對齊 1 2 3 4 5 6 box { 	text-align :left ; 		//向左對齊 	text-align :right ; 	//向右對齊 	text-align :center; 	//置中 	text-align :justify; //使左右對齊本文 } 
 
text-indent 首行處理 1 2 3 4 5 6 7 8 9 .box  {	   text-indent  : 36px ; 	  text-indent  : -36px ; 	 	margin-left  : 36px ;  	text-indent  : -36px ; } 
 
word-break 文字斷行規則 1 2 3 4 5 6 7 8 9 box { 	word-break : break-all; } 
 
white-space 空白與換行處理 1 2 3 4 5 6 7 8 9 10 box { 	white-space : pre-line; } 
 
writing-mode and inline-size(雖然 display:block 也會影顯寬度) 
writing-mode 文字顯示的方向
horizontal-tb : 水平顯示(default) 
vertical-rl : 由右到左垂直顯示方式 
vertical-lr : 由左到右的垂直顯示方式 
 
 
inline-size 影響一个元素的width 或 height, 取决于writing-mode
fit-content  
max-content 
min-content 
 
 
width 也可做以下設定(同 writing-mode=horizontal-tb 時 inline-size)
fit-content 
max-content 
min-content 
 
 
 
transition 屬性改變漸變效果 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 <style > .box {	 	width : 200px ; 	height :100px ; 	border-radius : 30px ; 	text-align : center; 	line-height : 100px ; 	border : 2px  solid orange; 	 	transition : all 1s  ease-in; } .box :hover  {	background : orange; 	color : white; 	cursor : pointer; } </style > <body > 	<div  class ="box" >  		Box 	</div >  </body > 
 
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 <style > .box {	 	width : 200px ; 	height :100px ; 	border-radius : 30px ; 	text-align : center; 	line-height : 100px ; 	border : 2px  solid orange; 	background : orange; 	font-size : 24px ; 	 	transition : all 0.3s  ease-in; } .box :hover  {		transform : rotate (360deg ); } .box2 { 	position : absolute; 	width : 200px ; 	height :100px ; 	border-radius : 30px ; 	text-align : center; 	line-height : 100px ; 	background : pink; 	top : 50% ; 	left : 50% ; 	transform : translate (-50% , -50% ) }	 </style > <body > 	<div  class ="box" >  		Box 	</div >  	<div  class ="box2" >  		Box2 	</div >  </body > 
 
position & z-index position 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 <style > /* static 預設定位值 relative 相對定位 : 相對自己的位置(還是佔有原本的位置)  absolute 絕對定位 : 往父層一層一層找到不是 static 的位置 fixed 固定定位 : 相對瀏覽器(viewport) 的位置 可設定: top,left,right,bottom  ==== fixed  ====   移至垂直中 	top : 0 ; 	bottom :0 ; 	margin : auto;   移至水平中 	left : 0 ; 	right : 0 ; 	margin : auto; */ .box1 { 	position : fixed; 	width : 100px ; 	height : 100px ; 	/* top: 50%; 	left :50%  */ 	top : 0 ; 	bottom :0 ; 	left : 0 ; 	right : 0 ; 	margin : auto; 	border : 1px  solid black; } .box2 { 	position : relative; 	width : 100px ; 	height : 100px ; 	top : 20px ; 	left : 20px ; } .box3 { 	width : 100px ; 	height : 100px ; } .box4 { 	position : relative; 	width : 100px ; 	height : 100px ; } .box-41 { 	position : absolute; 	right : 10px ; 	top : 10px ; } .box5 { 	position : fixed; 	width : 100px ; 	height : 100px ; } </style > <body > 	<div  class ="debug" >  		<div  class ="box1" > 111</div >  		<div  class ="box2" > 222</div >  		<div  class ="box3" > 333</div >  		<div  class ="box4" >  			444 			<div  class ="box-41" > 444-1</div >  			<div  class ="box-42" > 444-2</div >  		</div >  		<div  class ="box5" > 555</div >  	</div >  </body > 
 
z-index  
position sticky (支援較不普遍) 1 2 3 4 5   .box2  {	position : sticky; 	top : 100px ; } 
 
display 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 <style > 	.wrap { 		margin : 10px ; 		font-size : 24px ; 	} 	/* display: block; 		div  deafult is  "display : block;" 		height ,width   可調 		margin ,padding  可調 */ 	.box1 { 		display : block; 		width : 100px ; 		height : 100px ; 		margin : 5px  5px ; 		padding : 5px  5px ; 	} 	/* display: inline; 		height ,width   不可調 		margin  左右可調,上下不可調 		padding  左右可調,上下可調但不影響隔壁元件(會影響 background ) */ 	.box2 { 		display : inline; 		width : 100px ; 		height : 100px ; 		margin : 5px  5px ; 		padding : 5px  5px ; 	} 	/* inline-block 		height  可調 		width   可調 		margin  可調 		padding  可調 */ 	.box3 { 		display : inline-block; 		width : 100px ; 		height : 100px ; 		margin : 5px  5px ; 		padding : 5px  5px ; 	} </style > <div  class ="debug" > 	<div  class ="wrap" >  		<div  class ="box1" > 111</div >  		<div  class ="box1" > 222</div >  		<div  class ="box1" > 3333</div >  	</div >  	<div  class ="wrap" >  		<div  class ="box2" > 1111</div >  		<div  class ="box2" > 2222</div >  		<div  class ="box2" > 3333</div >  	</div >  	<div  class ="wrap" >  		<div  class ="box3" > 111</div >  		<div  class ="box3" > 222</div >  		<div  class ="box3" > 333</div >  	</div >  	<div  class ="wrap" >  		<div  class ="box2" > 1111</div >  		<div  class ="box2" > 2222</div >  		<div  class ="box2" > 3333</div >  	</div >  </div > 
 
visibility visible(default) - 可見 hidden - 隱藏但還佔位置 collapse 
在表格的 row 或 column (row、row group、column 和 column group 元素,也就是分別為 HTML 中的 tr、tbody、col 和 colgroup 元素) 使用 visibility: collapse 時:
會導致整個 row 或 column 從顯示結果中刪除,原本佔用的空間會讓其他內容使用,也就是說顯示結果很像是將 display: none 應用在表格的 row 或 column 一樣 
與 collapsed column 或 row (合併欄或合併列) 相交 (intersect) 的 spanned row 或 column (跨欄或跨列) 的內容會被裁切掉 (clipped) 
可以在不強制重新佈局 (re-layout) 表格的情況下,使用動態效果來刪除表格的 row 或 column 
 
 
對 table cell (也就是 HTML 中的 td 或 th 元素) 使用 visibility: collapse 時,效果相當於 visibility: hidden 
除了上述以外的其他元素使用 visibility: collapse 時,效果相當於 visibility: hidden 
 
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 <!DOCTYPE html > <html  lang ="en" > <head > 	<meta  charset ="UTF-8" >  	<meta  name ="viewport"  content ="width=device-width, initial-scale=1.0" >  	<meta  http-equiv ="X-UA-Compatible"  content ="ie=edge" >  	<title > Document</title >  	<style >  		table  { 			outline : 1px  solid; 		} 		td  { 			outline : 1px  solid; 		} 		.collapse { 			visibility : collapse; 		} 	</style >  </head > <body > 	<table >  		<tr >  			<td > 1.1</td >  			<td  class ="collapse" > 1.2</td >  			<td > 1.3</td >  		</tr >  		<tr  class ="collapse" >  			<td > 2.1</td >  			<td > 2.2</td >  			<td > 2.3</td >  		</tr >  		<tr >  			<td > 3.1</td >  			<td > 3.2</td >  			<td > 3.3</td >  		</tr >  	</table >  </body > </html > 
 
Box model 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <style > 	.item { 		height : 100px ; 		width : 200px ; 		margin : 10px ; 		padding : 20px ; 		border : 3px  solid black; 		/*  content-box(default):width/height 不含 padding and border 			  border -box::width/height 不含 padding and border 		*/ 		box-sizing : border-box; 	} 	 </style > <body > 	<div  class ="box debug" >  		<div  class ="item" > 1</div >  		<div  class ="item" > 2</div >  		<div  class ="item" > 3</div >  	</div >  </body > 
 
max-width/min-width
1 2 3 4 .box  {	min-width : 300px ; 	max-width : 1200px ; } 
 
border-radius 圓角屬性
1 2 3 4 .box  {	 	border-radius : 0  10px  0  10px ; } 
 
 
Flex 說明 外容器  主軸 : main axis 交錯軸 : cross axis
軸線 
屬性 
選  項 
 
 
主軸 
display 
flex, inline-flex 
 
主軸 
flex-direction(方向) 
row(default), row-reverse, column, column-reverse 
 
主軸 
flex-wrap(換行) 
nowrap(default), wrap, wrap-reverse 
 
交錯軸 
justify-content(主軸對齊) 
flex-start, flex-end, center, space-between, space-around 
 
交錯軸 
align-items(單行交錯軸對齊) 
flex-start, flex-end, center, space-between, space-around,stretch,baseline 
 
交錯軸 
align-content(多行交錯軸對齊) 
flex-start, flex-end, center, space-between, space-around,stretch 
 
內元件 
屬性 
選  項 
 
 
Flex(伸縮屬性) 
flex-grow, flex-shrink 和 flex-basis 
 
align-self 
個別調整子元素在交錯軸線的位置,屬性與 align-ite相同 
 
Order 
可以重新定義元件的排列順序, default 0, 由小到大 
 
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 <style > 	.debug *, .debug { 		outline : 1px  solid gold; 	} 	.flex { 		 		 		display : flex; 		width : 550px ; 		height : 200px ; 		 		 		flex-direction : row; 		/* flex-wrap(換行): nowrap(default) | wrap | wrap-reverse 		   若不換行自動縮小 */ 		flex-wrap : wrap; 		/* justify-content(主軸對齊) 		   flex -start:預設值,對齊最左邊的 main  start 			 flex -end:對齊最左邊的 main  end 			 center:水平置中 			 space-between:平均分配內容元素,左右元素將會與 main  start 和 main  end 貼齊 			 space-around:平均分配內容元素,間距也是平均分配 */ 		justify-content : space-around; 		 		/* align-items(單行交錯軸對齊) 		   flex -start:對齊最上面的 cross start 			 flex -end:對齊最下面的 cross end 			 center:垂直置中 			 stretch:預設值,將內容元素全部撐開至 Flexbox 的高度(item 設 height  即無效 			 baseline:以所有內容元素的基線作為對齊標準 */ 		 		/* align-content(多行交錯軸對齊)  			flex -start:對齊最上面的 cross start 			flex -end:對齊最下面的 cross end 			center:垂直置中 			space-between:將第一行與最後一行分別對齊最上方與最下方 			space-around:每行平均分配間距 			stretch:預設值,內容元素全部撐開 */ 			align-content : space-around; 		margin : 10px  0  	} 	.item { 		 		margin : 10px ; 		width : 100px ; 		height : 50px ; 		/* flex(伸縮屬性) 屬性是flex-grow, flex-shrink 和 flex-basis的簡寫,默認值為 0 1 auto 			 flex-grow  設定 flex 元素 的延伸因子,默認值0  (按比例延伸)可設 某些1 ,某些2   即 1 :2  延伸 			 flex-shrink  指定了 flex 元素 的收縮規則,默認值是 1  			 flex-basis  指定了 flex 元素 在主軸方向上的初始大小  			 		flex  item 放進 flex  容器,並不能保證能夠按照 flex-basis  設置的大小展示。瀏覽器會根據 flex-basis  計算主軸是否有剩餘空間 					 1 . 當指定一個flex-basis 值的時候,width 屬性 就被忽略了 					 2 . min-width 和max-width 會限制flex-basis 值 			 */ 		flex-grow : 1 ; 		flex-shrink : 1 ; 		 		 		 		 	} </style > <body > 	<div  class ="flex debug" >  		<div  class ="item" > 1</div >  		<div  class ="item" > 2</div >  		<div  class ="item" > 3</div >  		<div  class ="item" > 4</div >  		<div  class ="item" > 5</div >  		<div  class ="item" > 6</div >  	</div >  </body > 
 
flex (row) 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 <style > 	.flex { 		display : flex; 	} 	.inline-flex { 		display : inline-flex; 	} 	.container { 		 		background-color : coral; 		flex-direction : row;	  		flex-wrap : nowrap;  	  		  		justify-content : space-evenly;  		height : 700px ; 		align-items : center;  		 		 		 	} 	.item { 		padding : 30PX ; 		 		background : #777 ; 		text-align : center; 		font-size : 30px ; 		color : #fff ; 		border : 1px  solid #f00 ; 	} 	 	/* .item1 { 		font-size : 70px ; 	} */ 	 	 	/* .item1 { 		order : 1 ; 		align-self : flex-start; 	} 	.item5 { 		order : -1 ; 		align-self : flex-end; 	} */ </style > <div  class ="container flex" > 	<div  class ="item item1" > A</div >  	<div  class ="item item2" > B</div >  	<div  class ="item item3" > C</div >  	<div  class ="item item4" > D</div >  	<div  class ="item item5" > E</div >  </div > 
 
inline-flex(row) 1 2 3 4 5 6 7 <div  class ="container inline-flex" > 	<div  class ="item item1" > A</div >  	<div  class ="item item2" > B</div >  	<div  class ="item item3" > C</div >  	<div  class ="item item4" > D</div >  	<div  class ="item item5" > E</div >  </div > 
 
flex (column) 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 <style > 	.container-column { 		 		background-color : coral; 		flex-direction : column;	  		flex-wrap : nowrap;  	  		  		justify-content : space-around;  		height : 700px ; 	} 	.item-column { 		padding : 30PX ; 		 		background : #777 ; 		text-align : center; 		font-size : 30px ; 		color : #fff ; 		border : 1px  solid #f00 ; 		width : 70px ; 	} </style > <div  class ="container-column flex" > 	<div  class ="item-column item1" > A</div >  	<div  class ="item-column item2" > B</div >  	<div  class ="item-column item3" > C</div >  	<div  class ="item-column item4" > D</div >  	<div  class ="item-column item5" > E</div >  </div > 
 
flex (flex-grow, flex-shrink, flex-basis) 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 <style > 	.container-flex { 		 		background-color : coral; 		flex-direction : row;	  		flex-wrap : nowrap;  	  		  		justify-content : space-evenly;  		height : 700px ; 		align-items : center;  		 		 		 	} 	.item-flex { 		padding : 30PX ; 		margin :10px ; 		background : #777 ; 		text-align : center; 		font-size : 30px ; 		color : #fff ; 		border : 1px  solid #f00 ; 	} 	.item1-flex { 		width : 200px ; 		 		 		 		 		 		flex-basis : 100px ; 		 		 	} 	.item5-flex { 		width : 200px ; 		 		 		 		 		 	} </style > <div  class ="container-flex flex" > 	<div  class ="item-flex item1-flex" > A</div >  	<div  class ="item-flex item2-flex" > B</div >  	<div  class ="item-flex item3-flex" > C</div >  	<div  class ="item-flex item4-flex" > D</div >  	<div  class ="item-flex item5-flex" > E</div >  </div > 
 
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 <style > 	.debug *, .debug { 		outline : 1px  solid gold 	} 	html  { 		font-size : 24px ; 	} 	html , body , h1  ,h2  ,h3  ,h4  ,h5  ,h6  ,p  { 		padding : 0 ; 		margin : 0 ; 	} 	body  { 		margin : 10px  	} 	.container { 		display : grid; 		 		 		 		 		grid-template-columns : repeat (3 , 1 fr);   	 		 		 		grid-auto -rows: 100px ; 		 		grid-column-gap : 10px ;    	grid-row-gap: 1em ; 	} 	.box1 {     grid-column-start: 1 ;     grid-column-end: 4 ;     grid-row-start: 1 ;     grid-row-end: 3 ; 	} 	.box2 { 			grid-column-start: 1 ; 			grid-row-start: 3 ; 			grid-row-end: 5 ; 	} </style > <body > 	<div  class ="container debug" >  		<div  class ="box1" > 111</div >  		<div  class ="box2" > 222</div >  		<div  class ="box3" > 333</div >  		<div  class ="box4" > 444</div >  		<div  class ="box5" > 555</div >  	</div >  </body > 
 
     
 
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 <style > 	 	/* header 5 格 	   main  5  格 	   footer  4  格(第一格不占用) */ 	.container { 		grid-template-areas:  		 'header header header header header' 		 'main main main main main' 		 '!.footer footer footer' 	} 	 	.main { 		grid-area: main; 	} 	.header { 		grid-area: header; 	} 	.footer { 		grid-area: footer; 	} 	 	.main { 		grid-area: 1 /2 /8 /3 ; 	} </style > 
 
ol/ul/li 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ul  {	 	list-style-type :square; 	 	list-style-position :inside; 	// list-style-image  用來將某個圖案設定為記號 	list-style-image :url ("circle.gif" ); 	// list-style  : list-style-tyle、list-style-position、及 list-style-image 	list-style: url ("circle.gif" ) none inside; } 
 
other cursor 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 box { 	 	cursor: pointer; } 
 
1 2 3 4 5 6 7 .box  {	 	box-shadow : 10px  5px  5px  black;	 	 	box-shadow : 2px  2px  2px  1px  rgba (0 , 0 , 0 , 0.2 ); } 
 
1 2 3 4 5 6 .box  {	 	font-family : "Microsoft JhengHei" ;  	font-family : "Times New Roman" ; } 
 
vertical-align 可以用來設計網頁中圖片在垂直方向的對齊方式
baseline : 預設值,元素在該行的基礎線上,大約在文字的中間位置,並不美觀 
sub : 圖片垂直對齊該行本文的下標位置 
super : 圖片垂直對齊該行本文的上標位置 
top : 圖片垂直對齊該行元素的最高位置 
:text-top : 圖片垂直對齊該行文字的最高位置 
middle : 圖片垂直對齊該行文字的置中位置 
bottom : 圖片垂直對齊該行元素的最低位置 
text-bottom : 圖片垂直對齊該行文字的最低位置 
% : 以百分比來讓圖片垂直對齊該行文字,可以有負值 
 
1 2 3 box {   vertical-align :middle; } 
 
min-height 1 2 3 4 .mini-page  {  min-height : calc (100vh  - 424px ); } 
 
opacity 不透明度 1 2 3 4 opacity : 1 ;opacity : 0 ;
 
允許在聲明CSS屬性值時執行一些計算它可以用在如下場合<length>、<frequency>, <angle>、<time>、<percentage>、<umber>、或 <integer> 
+ 和 - 運算符的兩邊必須要有空白字符 
* 和 / 這兩個運算符前後不需要空白字符,但如果考慮到統一性,仍然推薦加上空白符 
 
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 .games  .item  {	filter : brightness (0.8 ) } .games  .item :hover  {	filter : brightness (1 ) } 
 
RWD 相關 1 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
overflow 1 2 3 4 5 6 7 8 9 10 .box  {	overflow : visible; 	 } 
 
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 .title { color : red; } @media(max-width:768px) { 	.title { 		color : blue; 	} } @media(max-width:375px) { 	.title { 		color : yellow; 	} } .title { color : red; } @media(min-width:375px) { 	.title { 		color : yellow; 	} } @media(min-width:768px) { 	.title { 		color : blue; 	} } 
 
參考