Website Series 3 - CSS

57
CSS 5/7 - Website Series 3 [email protected]

Transcript of Website Series 3 - CSS

Page 1: Website Series 3 - CSS

CSS5/7 - Website Series 3

[email protected]

Page 2: Website Series 3 - CSS

Effect of CSSHTML

Title1 Title2 Title3 Title4HTML + CSS

Title1 Title2 Title3 Title4

Page 3: Website Series 3 - CSS

Concept Of CSS Finding tags and modify them Make things beautiful Different browser may have different outcome

Page 4: Website Series 3 - CSS

Places to Put CSS<html><head><link rel=“stylesheet” href=“css/style.css”><style>…</style></head><body><div style=“…”></div></body></html>

Page 5: Website Series 3 - CSS

Places to Put CSS<html><head><link rel=“stylesheet” href=“css/style.css”><style>…</style></head><body><div style=“…”></div></body></html>

No need to select

Page 6: Website Series 3 - CSS

Places to Put CSS<html><head><link rel=“stylesheet” href=“css/style.css”><style>…</style></head><body><div style=“…”></div></body></html>

Need to select

No need to select

Page 7: Website Series 3 - CSS

Places to Put CSS<html><head><link rel=“stylesheet” href=“css/style.css”><style>…</style></head><body><div style=“…”></div></body></html>

Need to select

No need to select

Put everything in <style> into a .css

file

Page 8: Website Series 3 - CSS

Places to Put CSS<html><head><link rel=“stylesheet” href=“css/style.css”><style>…</style></head><body><div style=“…”></div></body></html>

Need to select

No need to select

Put everything in <style> into a .css

file

Page 9: Website Series 3 - CSS

Places to Put CSS<html><head><link rel=“stylesheet” href=“css/style.css”><style>…</style></head><body><div style=“…”></div></body></html>

Need to select

No need to select

Put everything in <style> into a .css

file

Page 10: Website Series 3 - CSS

Places to Put CSS<html><head><link rel=“stylesheet” href=“css/style.css”><style>…</style></head><body><div style=“…”></div></body></html>

Need to select

No need to select

Put everything in <style> into a .css

file

Page 11: Website Series 3 - CSS

How it workdiv.box {

background:white;border: 2px solid blue;width: 200px;height: 200px;

}

<div class=“box”></div>

Page 12: Website Series 3 - CSS

How it workdiv.box {

background:white;border: 2px solid blue;width: 200px;height: 200px;

}

<div class=“box”></div> Selector

Page 13: Website Series 3 - CSS

How it workdiv.box {

background:white;border: 2px solid blue;width: 200px;height: 200px;

}

<div class=“box”></div> Selector

Style

Page 14: Website Series 3 - CSS

CSS Selector

Tag#id.class [attributes] : filter

Page 15: Website Series 3 - CSS

http://flukeout.github.io/

Page 16: Website Series 3 - CSS

CSS Selector Syntax (1)Selector example* AllE E tags inputE F F tags inside E tags input textareaE>F F tags as child of E div>pE+F F tags adjacent to E H1+pE.C E tags with C class p.warningE#I E tag with id as I input#nameE[A=V] ~ attribute A equals V input[type=‘text’]E[A^=V] ~ attribute A starts with V div[title^=‘my’]E[A$=V] ~ attribute A ends with V a[href$=‘.pdf’]E[A!=V] ~ attribute A not equal to V form[method!=‘POST’]E[A*=V] ~ attribute A contains V a[href*=‘google.com’]

Page 17: Website Series 3 - CSS

CSS Selector Syntax : filter (2)Filter example

:hover when element being hovered a:hover

:first-child As first child in its parent element li:first-child

:last-child As last child in its parent element li:last-child

:nth-child(n|even|odd) As nth-child ~ li:nth-child ( 2 ) li:nth-child ( odd )

:nth-child(Xn+Y) li:nth-child ( 5n+1 )

:even

:odd

:not(selector) Elements that is not selected by the selector :not( img [ src*=‘dog’ ] )

Page 18: Website Series 3 - CSS

Example

Page 19: Website Series 3 - CSS

Example

Page 20: Website Series 3 - CSS

Example

.container .content:first-child

.container .content.info

Page 21: Website Series 3 - CSS

Example

Page 22: Website Series 3 - CSS

Example

Page 23: Website Series 3 - CSS

Example

.thumb img

.pic-container > img

Page 24: Website Series 3 - CSS

Example

Page 25: Website Series 3 - CSS

Example

Page 26: Website Series 3 - CSS

.info .vislble-data:last-child

.visible-data[data-type=‘gender’]

Example

Page 27: Website Series 3 - CSS

Example

Page 28: Website Series 3 - CSS

Text Related Styles

Page 29: Website Series 3 - CSS

Text Related Styles 字體適用順序

font-family: "微軟正黑體 ",Arial, Helvetica, sans-serif

Page 30: Website Series 3 - CSS

Text Related Styles 字體適用順序

font-family: "微軟正黑體 ",Arial, Helvetica, sans-serif 字體大小

font-size: 16px; 14pt, small, medium, large, x-large……

Page 31: Website Series 3 - CSS

Text Related Styles 字體適用順序

font-family: "微軟正黑體 ",Arial, Helvetica, sans-serif 字體大小

font-size: 16px; 14pt, small, medium, large, x-large……

行高line-height: 20px;

Page 32: Website Series 3 - CSS

Text Related Styles 字體適用順序

font-family: "微軟正黑體 ",Arial, Helvetica, sans-serif 字體大小

font-size: 16px; 14pt, small, medium, large, x-large……

行高line-height: 20px;

水平位置text-align: center;

Page 33: Website Series 3 - CSS

CSS Block Model

Content

Page 34: Website Series 3 - CSS

CSS Block Model

Padding

Content

Page 35: Website Series 3 - CSS

Border

CSS Block Model

Padding

Content

Page 36: Website Series 3 - CSS

MarginBorder

CSS Block Model

Padding

Content

Page 37: Website Series 3 - CSS

MarginBorder

CSS Block Model

Padding

Content

Top

Bottom

RightLeft

Page 38: Website Series 3 - CSS

Try itdiv.box {display: block;background: white;margin: 10px 15px;padding: 10px;border: 2px solid blue;border-radius: 2px;width: 200px;height: 200px;color: #AAAAAA;}

Hi~~~

<div class=“box”></div>

Page 39: Website Series 3 - CSS

some selector {display: …. ;…

}

Page 40: Website Series 3 - CSS

some selector {display: …. ;…

}

Page 41: Website Series 3 - CSS

CSS layout Ordinary layout Use position properties Float Display property: table, inline-block (Flex) (Grid System)

Page 42: Website Series 3 - CSS

Ordinary Types of display

Page 43: Website Series 3 - CSS

Ordinary Types of displayblock

<div><div></div>

</div><p></p>

Page 44: Website Series 3 - CSS

Ordinary Types of displayblock

<div><div></div>

</div><p></p>

inline

<div>123123<span>hahaha</

span>123213</div>

123123 123213hahaha

Page 45: Website Series 3 - CSS

Position property Static Relative Absolute Fixed

@layout_ex_1.html

Page 46: Website Series 3 - CSS

.container

Page 47: Website Series 3 - CSS

.container

.nav

Page 48: Website Series 3 - CSS

.container

.content.nav

Page 49: Website Series 3 - CSS

.container

.content

.content.nav

Page 50: Website Series 3 - CSS

3 Ways To Make That Page

Page 51: Website Series 3 - CSS

3 Ways To Make That Page Float:文繞圖的方式

Page 52: Website Series 3 - CSS

3 Ways To Make That Page Float:文繞圖的方式 Table:用表格

Page 53: Website Series 3 - CSS

3 Ways To Make That Page Float:文繞圖的方式 Table:用表格 Inline-block:…痾我不知道這要怎麼形容…

Page 54: Website Series 3 - CSS

3 Ways To Make That Page Float:文繞圖的方式 Table:用表格 Inline-block:…痾我不知道這要怎麼形容… @layout_ex_2.html

Page 55: Website Series 3 - CSS

:hover Match when element is being hovered. It can replace some functions that JavaScript do.

(It can do a lot of magical things, but we will not cover today.)

Page 56: Website Series 3 - CSS

Conclusion Selector & Properties Many ways to layout a page, choice a way that is most logical

and fit to the page you are building. Use it wisely can save a lot of effort in JavaScript.

We will come back to RWD(Response Web Design) laterhttp://fundesigner.net/responsive-web-design-explain/