coding potpourri: css

118
CSS: Cascading Style Sheets Tom Boone Loyola Law School – Los Angeles [email protected] h=p://www.slideshare.net/tomboone #sc_drag_crop { bottom: 25px; textalign: center; right: 10px; minwidth: 30px; padding: 0 10px; } Tuesday, July 26, 11

Upload: tom-boone

Post on 28-Jan-2015

117 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Coding Potpourri: CSS

CSS:  Cascading  Style  SheetsTom  Boone

Loyola  Law  School  –  Los  [email protected]

h=p://www.slideshare.net/tomboone

#sc_drag_crop  {          bottom:  -­‐25px;          text-­‐align:  center;          right:  10px;          min-­‐width:  30px;          padding:  0  10px;}

Tuesday, July 26, 11

Page 2: Coding Potpourri: CSS

2

Without  CSS,  all  content  is  already  on  the  page.

Tuesday, July 26, 11

Page 3: Coding Potpourri: CSS

3

Without  CSS,  most  content  is  unreadable.

Tuesday, July 26, 11

Page 4: Coding Potpourri: CSS

4

For  example...

Tuesday, July 26, 11

Page 5: Coding Potpourri: CSS

CascadingStyleSheets

Tuesday, July 26, 11

Page 6: Coding Potpourri: CSS

CascadingStyleSheets

Tuesday, July 26, 11

Page 7: Coding Potpourri: CSS

BrowserStyleSheet

#1

SiteStyleSheet

#2

UserStyleSheet

#3

Tuesday, July 26, 11

Page 8: Coding Potpourri: CSS

BrowserStyleSheet

#1

SiteStyleSheet

#2

UserStyleSheet

#3

Default  Styles

Tuesday, July 26, 11

Page 9: Coding Potpourri: CSS

BrowserStyleSheet

#1

SiteStyleSheet

#2

UserStyleSheet

#3

***Website  Styles***

Tuesday, July 26, 11

Page 10: Coding Potpourri: CSS

BrowserStyleSheet

#1

SiteStyleSheet

#2

UserStyleSheet

#3

User  Overrides

Tuesday, July 26, 11

Page 11: Coding Potpourri: CSS

CascadingStyleSheets

Tuesday, July 26, 11

Page 12: Coding Potpourri: CSS

CascadingStyleSheets

Tuesday, July 26, 11

Page 13: Coding Potpourri: CSS

Style

Tuesday, July 26, 11

Page 14: Coding Potpourri: CSS

Style100  pt

Tuesday, July 26, 11

Page 15: Coding Potpourri: CSS

StyleTuesday, July 26, 11

Page 16: Coding Potpourri: CSS

Style300  pt

Tuesday, July 26, 11

Page 17: Coding Potpourri: CSS

StyleTimes  New  Roman

Tuesday, July 26, 11

Page 18: Coding Potpourri: CSS

StyleTuesday, July 26, 11

Page 19: Coding Potpourri: CSS

StyleHelveAca

Tuesday, July 26, 11

Page 20: Coding Potpourri: CSS

StyleBlack

Tuesday, July 26, 11

Page 21: Coding Potpourri: CSS

StyleTuesday, July 26, 11

Page 22: Coding Potpourri: CSS

StyleBlue

Tuesday, July 26, 11

Page 23: Coding Potpourri: CSS

Style#0000FF

Tuesday, July 26, 11

Page 24: Coding Potpourri: CSS

StyleBold

Tuesday, July 26, 11

Page 25: Coding Potpourri: CSS

StyleItalic

Tuesday, July 26, 11

Page 26: Coding Potpourri: CSS

STYLEUppercase

Tuesday, July 26, 11

Page 27: Coding Potpourri: CSS

CascadingStyleSheets

Tuesday, July 26, 11

Page 28: Coding Potpourri: CSS

CascadingStyleSheets

Tuesday, July 26, 11

Page 29: Coding Potpourri: CSS

Three  Kinds  of  Stylesheets

Linked

Embedded

Inline

Tuesday, July 26, 11

Page 30: Coding Potpourri: CSS

Three  Kinds  of  Stylesheets

Linked

Embedded

Inline

Tuesday, July 26, 11

Page 31: Coding Potpourri: CSS

Inline  Styles

<p  style="font-­‐weight:  bold;">    Some  text</p>

Tuesday, July 26, 11

Page 32: Coding Potpourri: CSS

Inline  Styles

<p  style="font-­‐weight:  bold;">    Some  text</p>

Tuesday, July 26, 11

Page 33: Coding Potpourri: CSS

Inline  Styles

<p  style="font-­‐weight:  bold;">    Some  text</p>

Tuesday, July 26, 11

Page 34: Coding Potpourri: CSS

Three  Kinds  of  Stylesheets

Linked

Embedded

Inline

Tuesday, July 26, 11

Page 35: Coding Potpourri: CSS

Three  Kinds  of  Stylesheets

Linked

Embedded

Inline

Tuesday, July 26, 11

Page 36: Coding Potpourri: CSS

<head>    <title>A  page  title</title>    <style  type="text/css">        div#header  {            color:  #ffffff;            font-­‐weight:  bold;        }    </style></head>

Embedded  Stylesheet

Tuesday, July 26, 11

Page 37: Coding Potpourri: CSS

<head>    <title>A  page  title</title>    <style  type="text/css">        div#header  {            color:  #ffffff;            font-­‐weight:  bold;        }    </style></head>

Embedded  Stylesheet

Tuesday, July 26, 11

Page 38: Coding Potpourri: CSS

<head>    <title>A  page  title</title>    <style  type="text/css">        div#header  {            color:  #ffffff;            font-­‐weight:  bold;        }    </style></head>

Embedded  Stylesheet

Tuesday, July 26, 11

Page 39: Coding Potpourri: CSS

<head>    <title>A  page  title</title>    <style  type="text/css">        div#header  {            color:  #ffffff;            font-­‐weight:  bold;        }    </style></head>

Embedded  Stylesheet

Tuesday, July 26, 11

Page 40: Coding Potpourri: CSS

Three  Kinds  of  Stylesheets

Linked

Embedded

Inline

Tuesday, July 26, 11

Page 41: Coding Potpourri: CSS

Three  Kinds  of  Stylesheets

Linked

Embedded

Inline

Tuesday, July 26, 11

Page 42: Coding Potpourri: CSS

<head>    <title>A  page  title</title>    <link  rel="stylesheet"  type="text/css"  href="style.css"></head>

Linked  Stylesheet

Tuesday, July 26, 11

Page 43: Coding Potpourri: CSS

<head>    <title>A  page  title</title>    <link  rel="stylesheet"  type="text/css"  href="style.css"></head>

Linked  Stylesheet

Tuesday, July 26, 11

Page 44: Coding Potpourri: CSS

<head>    <title>A  page  title</title>    <link  rel="stylesheet"  type="text/css"  href="style.css"></head>

Linked  Stylesheet

Tuesday, July 26, 11

Page 45: Coding Potpourri: CSS

div#header  {          background-­‐color:  #000000;          color:  #ffffff;          border:  1px  solid  #ffffff;          font-­‐weight:  bold;}

ul.menu  {  list-­‐style-­‐type:  none;}

style.css

Tuesday, July 26, 11

Page 46: Coding Potpourri: CSS

div#header  {          background-­‐color:  #000000;          color:  #ffffff;          border:  1px  solid  #ffffff;          font-­‐weight:  bold;}

ul.menu  {  list-­‐style-­‐type:  none;}

style.css

LinkedStylesheet

Tuesday, July 26, 11

Page 47: Coding Potpourri: CSS

<head>    <title>A  page  title</title>    <link  rel="stylesheet"  type="text/css"  href="style.css"></head>

Linked  Stylesheet

Tuesday, July 26, 11

Page 48: Coding Potpourri: CSS

Three  Kinds  of  Stylesheets

Linked

Embedded

Inline

Tuesday, July 26, 11

Page 49: Coding Potpourri: CSS

Three  Kinds  of  Stylesheets

Linked

Embedded

Inline

Tuesday, July 26, 11

Page 50: Coding Potpourri: CSS

CascadingStyleSheets

Tuesday, July 26, 11

Page 51: Coding Potpourri: CSS

CascadingStyleSheets

Tuesday, July 26, 11

Page 52: Coding Potpourri: CSS

52

Anatomy  of  a  CSS  Rule

p  {color:  red;}

Tuesday, July 26, 11

Page 53: Coding Potpourri: CSS

53

Anatomy  of  a  CSS  Rule

p  {color:  red;}

Selector

Tuesday, July 26, 11

Page 54: Coding Potpourri: CSS

54

p  {color:  red;}

DeclaraAon

Anatomy  of  a  CSS  Rule

Selector

Tuesday, July 26, 11

Page 55: Coding Potpourri: CSS

55

p  {color:  red;}

DeclaraAon

Anatomy  of  a  CSS  Rule

Property Value

Selector

Tuesday, July 26, 11

Page 56: Coding Potpourri: CSS

56

p  {color:  red;}

Anatomy  of  a  CSS  Rule

Selector

Tuesday, July 26, 11

Page 57: Coding Potpourri: CSS

57

<p>some  text</p>

Anatomy  of  a  CSS  Rule

Selector

Tuesday, July 26, 11

Page 58: Coding Potpourri: CSS

58

p  {color:  red;}

Anatomy  of  a  CSS  Rule

Selector

Affects  EVERY  <p>  tag  on  the  page.

Tuesday, July 26, 11

Page 59: Coding Potpourri: CSS

59

<p>some  text</p>

Anatomy  of  a  CSS  Rule

Selector

Tuesday, July 26, 11

Page 60: Coding Potpourri: CSS

60

li  {color:  red;}

Anatomy  of  a  CSS  Rule

Selector

Tuesday, July 26, 11

Page 61: Coding Potpourri: CSS

61

<li>some  text</li>

Anatomy  of  a  CSS  Rule

Selector

Tuesday, July 26, 11

Page 62: Coding Potpourri: CSS

62

li  {color:  red;}

Anatomy  of  a  CSS  Rule

Selector

Affects  EVERY  <li>  tag  on  the  page.

Tuesday, July 26, 11

Page 63: Coding Potpourri: CSS

63

<li>some  text</li>

Anatomy  of  a  CSS  Rule

Selector

Tuesday, July 26, 11

Page 64: Coding Potpourri: CSS

64

SelecAng  more  specific  elements

Classes

IDs

Descendant  Selectors

Tuesday, July 26, 11

Page 65: Coding Potpourri: CSS

65

SelecAng  more  specific  elements

Classes

IDs

Descendant  Selectors

Tuesday, July 26, 11

Page 66: Coding Potpourri: CSS

66

<p  class="summary">some  text</p>

Classes

Tuesday, July 26, 11

Page 67: Coding Potpourri: CSS

67

<p  class="summary">some  text</p>

Classes

Tuesday, July 26, 11

Page 68: Coding Potpourri: CSS

68

p.summary  {color:  red;}

Classes

Selector

Tuesday, July 26, 11

Page 69: Coding Potpourri: CSS

69

p.summary  {color:  red;}

Classes

Selector

Tuesday, July 26, 11

Page 70: Coding Potpourri: CSS

70

p.summary  {color:  red;}

Classes

Selector

Affects  only  <p>  tags  assigned  a  “summary”  class.

Tuesday, July 26, 11

Page 71: Coding Potpourri: CSS

71

<p  class="summary">some  text</p>

Classes

Tuesday, July 26, 11

Page 72: Coding Potpourri: CSS

72

<p  class="summary">some  text</p><p>some  text</p>

Classes

Tuesday, July 26, 11

Page 73: Coding Potpourri: CSS

73

<p  class="summary">some  text</p><p>some  text</p>

<p  class="body">some  text</p>

Classes

Tuesday, July 26, 11

Page 74: Coding Potpourri: CSS

74

p.summary  {color:  red;}p.body  {color:  blue;}

Classes

Selector

Tuesday, July 26, 11

Page 75: Coding Potpourri: CSS

75

<p  class="summary">some  text</p><p>some  text</p>

<p  class="body">some  text</p>

Classes

Tuesday, July 26, 11

Page 76: Coding Potpourri: CSS

76

SelecAng  more  specific  elements

Classes

IDs

Descendant  Selectors

Tuesday, July 26, 11

Page 77: Coding Potpourri: CSS

77

SelecAng  more  specific  elements

Classes

IDs

Descendant  Selectors

Tuesday, July 26, 11

Page 78: Coding Potpourri: CSS

78

<p  id="summary">some  text</p>

IDs

Tuesday, July 26, 11

Page 79: Coding Potpourri: CSS

79

<p  id="summary">some  text</p>

IDs

Tuesday, July 26, 11

Page 80: Coding Potpourri: CSS

80

<p  id="summary">some  text</p>

IDs

Each  ID  can  only  appear  ONCE  on  a  page.

Classes  can  repeat.

Tuesday, July 26, 11

Page 81: Coding Potpourri: CSS

81

p#summary  {color:  red;}

IDs

Selector

Tuesday, July 26, 11

Page 82: Coding Potpourri: CSS

82

p#summary  {color:  red;}

IDs

Selector

Tuesday, July 26, 11

Page 83: Coding Potpourri: CSS

83

p#summary  {color:  red;}

IDs

Selector

Affects  only  <p>  tags  assigned  a  “summary”  id.

Tuesday, July 26, 11

Page 84: Coding Potpourri: CSS

84

<p  id="summary">some  text</p>

IDs

Tuesday, July 26, 11

Page 85: Coding Potpourri: CSS

85

<p  id="summary">some  text</p><p>some  text</p>

IDs

Tuesday, July 26, 11

Page 86: Coding Potpourri: CSS

86

<p  class="summary">some  text</p><p>some  text</p>

<p  class="summary">some  text</p>

IDs

Tuesday, July 26, 11

Page 87: Coding Potpourri: CSS

87

p#summary  {color:  red;}p.summary  {color:  blue;}

IDs

Selector

Tuesday, July 26, 11

Page 88: Coding Potpourri: CSS

88

<p  id="summary">some  text</p><p>some  text</p>

<p  class="summary">some  text</p>

IDs

Tuesday, July 26, 11

Page 89: Coding Potpourri: CSS

89

SelecAng  more  specific  elements

Classes

IDs

Descendant  Selectors

Tuesday, July 26, 11

Page 90: Coding Potpourri: CSS

90

SelecAng  more  specific  elements

Classes

IDs

Descendant  Selectors

Tuesday, July 26, 11

Page 91: Coding Potpourri: CSS

91

<ul>    <li>some  text</li>    <li>some  more  text</li></ul>

Descendant  Selectors

Tuesday, July 26, 11

Page 92: Coding Potpourri: CSS

92

<ul>    <li>some  text</li>    <li>some  more  text</li></ul>

Descendant  Selectors

Tuesday, July 26, 11

Page 93: Coding Potpourri: CSS

93

ul  li  {color:  red;}

Descendant  Selectors

Selector

White  space  between  selectors  means  the  la=er  must  be  a  “descendant”  of  the  former.

Tuesday, July 26, 11

Page 94: Coding Potpourri: CSS

94

<ul>    <li>some  text</li>    <li>some  more  text</li></ul>

Descendant  Selectors

Tuesday, July 26, 11

Page 95: Coding Potpourri: CSS

95

ul  li  {color:  red;}

Descendant  Selectors

Selector

<li>  tags  not  descended  from  <ul>  tags  will  NOT  be  affected.

Tuesday, July 26, 11

Page 96: Coding Potpourri: CSS

96

<ul>    <li>some  text</li>    <li>some  more  text</li></ul><ol>    <li>some  numbered  text</li>    <li>more  numbered  text</li></ol>

Descendant  Selectors

Tuesday, July 26, 11

Page 97: Coding Potpourri: CSS

97

ul  li  {color:  red;}ol  li  {color:  blue;}

Descendant  Selectors

Selector

Tuesday, July 26, 11

Page 98: Coding Potpourri: CSS

98

<ul>    <li>some  text</li>    <li>some  more  text</li></ul><ol>    <li>some  numbered  text</li>    <li>more  numbered  text</li></ol>

Descendant  Selectors

Tuesday, July 26, 11

Page 99: Coding Potpourri: CSS

99

<ul>    <li  class="first">some  text</li>    <li>some  more  text</li></ul>

Descendant  Selectors

Classes/IDs  can  be  combined  with  descendant  selectors

Tuesday, July 26, 11

Page 100: Coding Potpourri: CSS

100

ul  li.first  {color:  red;}

Descendant  Selectors

Selector

Classes/IDs  can  be  combined  with  descendant  selectors

Tuesday, July 26, 11

Page 101: Coding Potpourri: CSS

101

<ul>    <li  class="first">some  text</li>    <li>some  more  text</li></ul>

Descendant  Selectors

Classes/IDs  can  be  combined  with  descendant  selectors

Tuesday, July 26, 11

Page 102: Coding Potpourri: CSS

102

SelecAng  more  specific  elements

Classes

IDs

Descendant  Selectors

Tuesday, July 26, 11

Page 103: Coding Potpourri: CSS

103

Types  of  ProperAes

Background

ColorsImagesPosihonSize

Tuesday, July 26, 11

Page 104: Coding Potpourri: CSS

104

Types  of  ProperAes

Background

Tuesday, July 26, 11

Page 105: Coding Potpourri: CSS

105

Types  of  ProperAes

Border

ColorWidth

Style  (solid,  dashed,  do=ed)

Tuesday, July 26, 11

Page 106: Coding Potpourri: CSS

106

Types  of  ProperAes

Border

Tuesday, July 26, 11

Page 107: Coding Potpourri: CSS

107

Types  of  ProperAes

Font

FamilySize

Weight

Tuesday, July 26, 11

Page 108: Coding Potpourri: CSS

108

Types  of  ProperAes

Font

Tuesday, July 26, 11

Page 109: Coding Potpourri: CSS

109

Types  of  ProperAes

Posihoning

FloatClearDisplay

Tuesday, July 26, 11

Page 110: Coding Potpourri: CSS

110

Types  of  ProperAes

Posihoning

Tuesday, July 26, 11

Page 111: Coding Potpourri: CSS

111

Types  of  ProperAes

Text

ColorAlignmentLine  HeightDecorahon

Tuesday, July 26, 11

Page 112: Coding Potpourri: CSS

112

Types  of  ProperAes

Text

Tuesday, July 26, 11

Page 113: Coding Potpourri: CSS

113

p  {    color:  red;    font-­‐weight:  bold;}

A  DeclaraAon  can  contain  Values  for  mulAple  ProperAes.

Tuesday, July 26, 11

Page 114: Coding Potpourri: CSS

114

p,  li,  ul#menu  {    color:  red;    font-­‐weight:  bold;}

A  CSS  rule  can  contain  mulAple  *disAnct*  selectors

Tuesday, July 26, 11

Page 115: Coding Potpourri: CSS

115

Latest  Developments

Adaphve  Web  DesignA  single  web  page  with  CSS  that  adapts  

to  any  size  screen.

CSS3Developing  standard  that  includes  animahon,  rotahon,  scaling,  and  

skewing

Tuesday, July 26, 11

Page 116: Coding Potpourri: CSS

116

CSS  Resources

w3schools.com  CSS  Tutorialh=p://www.w3schools.com/css/

“CSS:  The  Missing  Manual”by  David  Sawyer  McFarland

“CSS:  The  Definihve  Guide”by  Eric  A.  Meyer

“Stylin’  with  CSS:  A  Designer’s  Guide”by  Charles  Wyke-­‐Smith

Tuesday, July 26, 11

Page 117: Coding Potpourri: CSS

117

Sorware

Google  Chrome/Safari“Inspect  Element”

FirefoxFirebug  -­‐  Add-­‐on

CSS  Edit  (Mac)

Tuesday, July 26, 11

Page 118: Coding Potpourri: CSS

118

Tom  BooneLoyola  Law  School  –  Los  Angeles

[email protected]=p://www.slideshare.net/tomboone

Tuesday, July 26, 11