1、CSS Links
links can be styled differently depending on what state they are in.
The four links states are:
a:link
- a normal, unvisited linka:visited
- a link the user has visiteda:hover
- a link when the user mouses over ita:active
- a link the moment it is clicked
Text Decoration
The text-decoration
property is mostly used to remove underlines from links:
a:link { text-decoration: none; } a:visited { text-decoration: none; } a:hover { color:red; text-decoration: underline; } a:active { text-decoration: underline; }
Advanced - Link Buttons
This example demonstrates a more advanced example where we combine several CSS properties to display links as boxes/buttons:
a:link, a:visited { background-color: #f44336; color: white; padding: 14px 25px; text-align: center; text-decoration: none; display: inline-block; } a:hover, a:active { background-color: red; }
2、CSS Lists
HTML Lists and CSS List Properties
In HTML, there are two main types of lists:
- unordered lists (<ul>) - the list items are marked with bullets
- ordered lists (<ol>) - the list items are marked with numbers or letters
The CSS list properties allow you to:
- Set different list item markers for ordered lists
- Set different list item markers for unordered lists
- Set an image as the list item marker
- Add background colors to lists and list items
Different List Item Markers
The list-style-type
property specifies the type of list item marker.
The following example shows some of the available list item markers:
ul.a { list-style-type: circle; } ul.b { list-style-type: square; } ol.c { list-style-type: upper-roman; } ol.d { list-style-type: lower-alpha; }
An Image as The List Item Marker
The list-style-image
property specifies an image as the list item marker:
ul { list-style-image: url('sqpurple.gif'); }