Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and...

20
Session 3.3.

Transcript of Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and...

Page 1: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Session 3.3.

Page 2: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

ObjectivesDesigning a listUnderstand basic selectorsUsing pseudo-classes and pseudo-elements

Page 3: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Designing a listList categoriesCode in HTMLTo define the appearance of the list marker,

use the stylelist-style-type: type;

where type is disc, circle, square, decimal, decimal-leading-zero, lower-roman, upper-roman, lower-alpha, upper-alpha, lower-greek, upper-greek, or none.

Page 4: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Designing a list

Page 5: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Designing a listTo insert a graphic image as a list marker,

use the stylelist-style-image: url(url);

where url is the URL of the graphic image file.

To set the position of list markers, use the stylelist-style-position: position;

where position is inside or outside.

Page 6: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Designing a listTo define all of the list style properties in

a single style, use the following style:list-style: type url(url) position;To set the indentation of a list, apply the

stylepadding-left: size;

where size is the length that the list should be indented.

Page 7: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Practice - Design a list1. Open the hs_styles.css of the Sunny Acres

website.2. For unordered lists within the nav element,

remove the bullet marker and set the padding-left property to 0 pixel.

3. For unordered lists nested within the section element, create a style rule that displays the image file flake.png as the bullet marker.

Page 8: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Basic Selector TypesSelector = Element on the page you want to

style.Three basic selector types:

Element selectorsClass selectorsId selectors

Page 9: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Basic Selector TypesElement Selectors:Global selectors based on individual HTML

elements

p { font-family: Arial, Helvetica, Sans Serif;}

ul {color: black;}

Page 10: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Class SelectorsAttributes applied to the HTML elements of

your choice.

Page 11: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

id SelectorsAttribute selector based on ID attributes

applied to HTML elements.

Page 12: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Class and id naming ConventionNo whitespace or special charactersCSS is case-sensitiveEstablish standards for your CSS and stay

consistent with them

Page 13: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Practice – Classes and Ids1. Add the id “hourslist” to the first unordered list

element within the section element.2. Add the class “directionslist” to the second

unordered list element within the section element.3. Delete style rule for the unordered lists within the

section element.4. Create a style rule for the unordered list with the

hourslist id that displays the image flake.png as the bullet marker.

5. Create a style rule for the unordered list with the directionslist class that the bullet type as square.

Page 14: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Using pseudo classes and elementsA pseudo-class is a classification of an

element based on its current status, position, or use in the document.

CSS pseudo-elements are used to add special effects to some selectors.

Syntax:selector:pseudo-class/pseudo-element {styles;}

Page 15: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Pseudo Example Example description

link a:link Selects all unvisited links

visited a:visited Selects all visited links

active a:active Selects the active link

hover a:hover Selects links on mouse over

focus input:focus Selects the input element which has focus

first-letter p:first-letter Selects the first letter of every <p> element

first-line p: first-line Selects the first line of every <p> element

first-of-type p: first-of-type

Selects every <p> element that is the first <p> element of its parent

first-child p:first-child Selects every <p> elements that is the first child of its parent

before p:before Insert before after every <p> element

after p:after Insert content after every <p> element

lang(language)

p: lang(it) Selects every <p> element with a lang attribute value starting with "it"

Page 16: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Using pseudo-classes and elementsExamples:a:link {

color:red;

text-decoration:none;

}

a: hover {

color:red;

text-decoration:underline;

}

Page 17: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Using pseudo classes and elementsExamples: p:first-letter {color:#ff0000;font-size:xx-large;}p:first-line {color:#0000ff;font-variant:small-caps;}

Page 18: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Using pseudo-classes and elementsExamples:

h1:before{content:url(banner.gif);}

h1:after{content:url(logo.gif);}

Page 19: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Using pseudo-classes and elementsExample:

nav ul li:first-of-type {

text-transform: uppercase;

}

Page 20: Session 3.3.. Objectives Designing a list Understand basic selectors Using pseudo-classes and pseudo-elements.

Practice - pseudo-classes and elements1. For the first list item of the unordered list within the nav

element, create a style rule to:a. Increase the font size to 150%b. Display the text in small capsc. Display the text in bold

2. For every hypertext link within the navigation list, create a style that removes underlining and set the font color to white.

3. When the user hovers the mouse pointer over list items in the navigation list, change the background color to the value (148, 51, 62).

4. When the user hovers a hypertext link in the navigation list, change the font color to yellow.