CSS3 (Cascading Style Sheets) is a styling language used to describe the appearance and layout of a web page. CSS3 selectors are used to target specific HTML elements on a page and apply styles to them. CSS3 provides various font properties to control the appearance of text on a web page, including font-size, font-family, and font-weight. CSS3 also offers a wide range of color options, including the use of RGB and HSL values, as well as the ability to set transparency levels. Background properties such as background-color and background-image can be used to set the background of an element. CSS3 borders provide options for controlling the width, style, and color of borders around elements. The box model refers to the rectangular structure used to represent an element on a web page, including its content, padding, borders, and margins. CSS3 animations allow for the creation of smooth and interactive transitions between styles, bringing more dynamic visual effects to web pages.
Topics covered:
What is CSS 3?
Selectors
Fonts
Colors
Backgrounds
Borders
Box Model
Animations
Video (in Bulgarian)
Presentation Content
What is CSS 3?
Cascading Style Sheets level 3 is the most recent iteration of CSS
It is divided into several separatedocuments called “modules”
CSS 3 has not been approved as a specification, but there are already a lot of properties that are supported in various browsers.
The earliest CSS 3 drafts were published in June 1999
Attribute Selectors
E[foo^=“bar”]
An E element whose “foo” attribute value begins exactly with the string “bar”
Example: a[src^="https://"]
E[foo$=“bar”]
An E element whose “foo” attribute value ends exactly with the string “bar”
E[foo*=“bar”]
An E element whose “foo” attribute value contains the substring “bar”
Structural Pseudo-classes
:root
The root of the document
E:nth-child(n)
An E element, the n-th child of its parent
E:nth-last-child(n)
An E element, the n-th child of its parent, counting from the last on
E:nth-of-type(n)
An E element, the n-th sibling of its type
E:nth-last-of-type(n)
An E element, the n-th sibling of its type, counting from the last one
E:last-child
An E element, last child of its parent
E:first-of-type
An E element, first sibling of its type
E:last-of-type
An E element, last sibling of its type
E:only-child
An E element, only child of its parent
E:only-of-type
An E element, only sibling of its type
E:empty
An E element that has no children (including text nodes)
Add an effect when changing from one style to another
Different timing functions:
ease, ease-in, ease-out, ease-in-out, linear
Example:
#id_of_element{
-webkit-transition: all 1s ease-in-out; -moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out; transition: all 1s ease-in-out;
}
2D Transformations
2D transforms are widely supported
Skew – skew element
transform: skew(35deg);
Scale – scale element
transform: scale(1,0.5);
Rotate – rotates element
transform: rotate(45deg);
Translate – moves element
transform: translate(10px, 20px);
3D Transformations
3D transforms are similar to 2D transforms
Only work in Safari and Chrome
X, Y and Z transformation
transform: rotateX(180deg);
transform: rotateY(180deg);
transform: rotateZ(180deg);
perspective: 800;
perspective-origin: 50% 100px;
translate3d, scale3d
Exercises
Using CSS3 make a rotating 3D Rubik Cube.
Using CSS3 make a text that is pulsing, i.e. gets bigger, then smaller, etc. while blinking with different colors.
Using CSS3 make a text bouncing around the screen (the browser).