1 / 17

LIST ITEMS

LIST ITEMS. ART340. Browser Defaults. By default, browsers automatically insert bullets before < ul > elements and numbers before < ol > elements.

eze
Download Presentation

LIST ITEMS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LIST ITEMS ART340

  2. Browser Defaults • By default, browsers automatically insert bullets before <ul> elements and numbers before <ol> elements. • Rendering of these elements is determined by the browser. • CSS resets can normalize differences. Source: coding.smashingmagazine.com

  3. list-style-type • This property selects the type of marker that appears before each list item. • Applies to the <ul>, <ol> & <li> element. • Most common values: none, disc (default), circle, square Source: coding.smashingmagazine.com Example: http://htmlandcssbook.com/code-samples/chapter-14/list-style-type.html

  4. list-style-position • Values: inside, outside, inherit • Allows you to pull the bullet inside the content area so it runs into the list content. • Default: outside Source: coding.smashingmagazine.com Example: http://htmlandcssbook.com/code-samples/chapter-14/list-style-position.html

  5. Appearance • Size: Bullet size changes with font size. • Color: Picks up browser defaults.

  6. list-style-image • Allows you to create custom bullets. • You can browse to attach an image to your bullets. • Can be buggy in IE. • Better to apply background image to <li>. • Tutorial: • http://css.maxdesign.com.au/listutorial/introduction.htm Example: http://htmlandcssbook.com/code-samples/chapter-14/list-style-image.html

  7. Navigations The most common use of the <ul> is the nav bar.

  8. Using Lists for Navigation • Two Methods: • Make the list items “display: inline;” into a horizontal bar • Use “float:left;” to line up the list items

  9. display: inline; ul#nav { list-style-type: none; margin: 0; padding: 0; } ul#nav li { display: inline; } HomeCategoriesAboutPortfolioContact

  10. Applying Style to inline nav • Once the items are inline, you can now apply style to the “a” elements. ul#nav li a { padding: 5px 20px; margin: 0px 2px; border: solid 1px black; background-color: red; text-decoration: none; } Home Categories About Portfolio Contact

  11. Floated Navigations • Turn off the bullets (list-style-type: none;). • Float each list item <li>. • Make the anchor elements display as block-level elements so dimensions can be set. • Format the anchor elements with styles.

  12. Floated Navigation Issue • When <li> list items are floated, the <ul> container will collapse when it contains only floated elements. • To fix, add “overflow: hidden;” to the <ul> or <ol>

  13. The :hover pseudo-class • Mainly used for links. • When someone place a cursor over it, the element changes. • Written like so: a:hover { }

  14. Pseudo-classes • a:link {color:#FF0000;}      /* unvisited link */ • a:visited {color:#00FF00;}  /* visited link */ • a:hover {color:#FF00FF;}  /* mouse over link */ • a:active {color:#0000FF;}  /* selected link */

  15. CSS Image Rollovers • To place a background-image on a navigation item, the float method is recommended. • The background image needs to be placed on the “a” element like so: #nav li { list-style-type: none; float: left;} #nav a { width: 100px; height 20px; background: url (welcome.jpg); } #nav a:hover { background: url (welcome_hover.jpg); }

  16. CSS Sprites • A popular method for image rollovers, is to use one image, and then change the background-position for each link state: a {background: #606 url(“welcome.jpg”) bottom left no-repeat; } a:hover {background: #fofurl(“welcome.jpg”) bottom top no-repeat; } Example: http://htmlandcssbook.com/code-samples/chapter-16/image-rollovers-and-sprites.html

  17. Class Example • http://www.cassreese.com/student/Navigation_Example/navigation.html#

More Related