– The !important Declaration– The execution order of the... – The !important Declaration– The execution order of the... – The !important Declaration– The execution order of the... Defini
Trang 1Cascading Style Sheet
Trang 4• Can be written in html or css file
• Consists of a list of rule sets
• A Rule set consists of:
Trang 7Introduction
-CSS added in HEAD section - EXTERNAL
• Html file
• Css file
Trang 16ID selector
• Definition:
– Apply CSS rule to only one ID.
– An ID selector can appear many times in CSS file – An ID selector can appear one time in html tag.
Trang 18– The !important Declaration
– The execution order of the
Trang 20Figure 1: Example of inheritance
Trang 21– The !important Declaration
– The execution order of the
Trang 23Grouping Selectors
• Example:
Trang 24– The !important Declaration
– The execution order of the
Trang 25Defining CSS rules to child selectors
Trang 26Defining CSS rules to child selectors
• Example:
Figure 3: Define CSS rules for child
Trang 27– The !important Declaration
– The execution order of the
Trang 28The !important Declaration
Trang 29The !important Declaration
• Example:
Figure 4: Example of !important declaration
Trang 30– The !important Declaration
– The execution order of the
Trang 31The execution order of the CSS rules
• Inline > internal > external
• !importance declaration has top priority
• More detail has higher priority
• Later has higher priority
Trang 32– The !important Declaration
– The execution order of the
Trang 33Adding Comments within Stylesheets
property:value;
}
Trang 35• Accepts a comma-separated list
• Enclose font that contains spaces with “xy z”
• Insert generic font at the end of list
• Five generic font-family values:
– serif
– sans-serif
– cursive
– monospace
Trang 38Font Embedding
• Used to include a font other than general
• Embed new font with @font-face
• To use this CSS rule, set two properties:
– font-family
– src
Trang 41• Controls size of text
• Can be defined in:
Trang 42• Example:
Figure 5: Example of font-size
Trang 44• Controls thickness of font
• Can take on different values:
Trang 45• Example:
Trang 48• Example:
Figure 7: Example of font-variant
Trang 51• Example:
Trang 53Multiple values for font property
• Set many font properties in one definition
• Use font property
• Syntax:
selector {
font: font-style_val
font-variant_val font-weight_val font-size_val font-family_val;
Trang 54Multiple values for font property
• Example:
Figure 9: Using font style
Trang 57• Example:
Trang 60• Example:
Figure 11: Example of word-spacing
Trang 63• Example:
Trang 66• Example:
Figure 13: Example of text-transform
Trang 69• Example:
Trang 72• Example:
Figure 15: Example of vertical-align
Trang 75• Example:
Trang 78• Example:
Figure 17: Example of text-decoration
Trang 81• Example:
Trang 84• Example:
Trang 87• Example:
Trang 89• Is applied throughout content area of element
• Is drawn behind background-image
Trang 90• Example:
Figure 21: Example of background-color
Trang 93• Example:
Trang 96• Example:
Figure 23: Example of background-repeat
Trang 99• Example:
Trang 102• Example:
Figure 25: Example of background-position
Trang 104Multiple values for background property
• Add many background properties in one definition
• Syntax:
selector {
background: bg_color
bg_image bg_repet bg_attach bg_position;
}
Trang 105Multiple values for background property
• Example:
Trang 107• Is a box that wraps around HTML elements
Trang 109width and height
• Defines width and
height of the content
Trang 110width and height
• Example:
Figure 28: Example of width and height
Trang 113• Example:
Trang 115• Sets space between element
border and content area
Trang 116• Example:
Figure 30: Example of padding
Trang 119• Example:
Trang 121Min and max dimensions
• Places restrictions on element’s size
Trang 123Example
Trang 125CSS Border
• For student!
Trang 127CSS outline
• For student!
Trang 128• Positioning
• CSS Float and Clear
• Pseudo-classes
• Reference
Trang 130• Example:
Figure 37: Example of using display
Trang 133• Example:
Trang 134– Define the visible portion of an element
• Positioning
• CSS Float and Clear
• Pseudo-classes
• Reference
Trang 135Define the visible portion of an element
• Use visible surface
Trang 136Define the visible portion of an element
• Example:
Figure 39: Visible portion of an element
Trang 137• CSS Float and Clear
• Pseudo-classes
• Reference
Trang 138• Default value
• Not uniquely positioned
• Are not affected by:
Trang 139• CSS Float and Clear
• Pseudo-classes
• Reference
Trang 140Figure 40: Relative positioning
Trang 141relative
Trang 142– absolute
– fixed – z-index
• CSS Float and Clear
• Pseudo-classes
• Reference
Trang 143• An absolute position element
– Is positioned relative to the first parent element
that has a position other than static, or <html> if
no such element exists, and its display is not
affected by other elements.
– Absolute positioning takes the element out of the normal document flow, and can overlap other
elements.
• Syntax:
Trang 144Figure 41: Absolute positioning
Trang 146• Based on the viewport window
• Can overlap other element
• Not move even if the window is scrolled
Trang 147– z-index
• CSS Float and Clear
• Pseudo-classes
• Reference
Trang 148Figure 42: Using z-index positioning
Trang 150CSS Float and Clear
• For students!
Trang 152• For students!
Trang 154• http://coursesweb.net/
• http://www.w3schools.com/