Comp 1537 - Week 2 - Css Basics
Comp 1537 - Week 2 - Css Basics
}
Braces wrap around multiple property-value pairs
Property keys followed by the colon symbol, a value, then the semicolon
Comments – multi-line, start with front-slash, asterisk, end in reverse
There are different types of selectors
Element selectors:
Use the element names to create selections
ID selector:
Uses the id attribute of any element
Each id attribute value has to be unique within the document!
Failing to adhere to this will cause problems in JavaScript code
Since JavaScript will assume only one element has that id attribute value
Class selectors:
Use the class attribute – which are added to elements
Name of class can be any alphabetic name (usually lower case)
Universal selector:
Uses the asterisk to select – usually used in tandem with other selectors
E.g., element or class
Attribute selectors:
Select an element based upon:
The existence of an attribute
The value of an attribute
Can be used in conjunction with other selectors
Pseudo selectors
Create pseudo elements/classes that don't actually exist
i.e., no element by that name
The element/class is something that is created on the spot to represent a
context/state
Some concepts:
Leading – space between lines
The term comes from the lead bars that were placed between blocks of text for printing presses
Tracking – the overall space between characters on a line
Kerning – the individual space between two characters
See examples …
Can be:
linear-gradient – single cycle
repeating-linear-gradient – repeats a pattern
Specified by:
[ <angle> | to <side-or-corner> ,]? <color-stop> [, <color-stop>]+
Can be:
radial-gradient – single cycle
repeating-radial-gradient – repeats a pattern
Specified by:
[ circle || <length> ] [ at <position> ]? ,
| [ ellipse || [<length> | <percentage> ]{2}] [ at <position> ]? ,
| [ [ circle | ellipse ] || <extent-keyword> ] [ at <position> ]? ,
| at <position> ,
<color-stop> [ , <color-stop> ]+
Use the:
transform property
:before and :after pseudo elements
Both insert content into the page for an element
CSS allows for clipping of content as well (again, images, text, etc.)
Can use two ways:
With CSS functions: circle, ellipse, and polygon
Works with Chrome, Firefox, Edge,
Advantages:
Create custom clipping of imagery, can use in tandem with shape-outside
Disadvantages:
Clipping doesn't mean crop – so empty space appears
Online book/tutorial:
https://developer.mozilla.org/en-US/docs/Web/CSS