7. CSS VARIABLES
• CSS variables can be used to store CSS
attribute values
• These can help maintain and easily update
code
• To declare a variable use the following syntax:
• To read a variable use:
fallback
11. CSS MEDIA QUERIES
• The @media rule is used in media queries to apply
different styles for different media types/devices.
• Media queries can be used to check many things, such
as:
• width and height of the viewport
• width and height of the device
• orientation (is the tablet/phone in landscape or portrait
mode?)
• resolution
• Using media queries are a popular technique for
delivering a tailored style sheet (responsive web design)
to desktops, laptops, tablets, and mobile phones.
12. CSS MEDIA QUERIES
• You can also use media queries to specify that
certain styles are only for printed documents or for
screen readers (mediatype: print, screen, or
speech)
• In addition to media types, there are also media
features. Media features provide more specific
details to media queries, by allowing to test for a
specific feature of the user agent or display device.
For example, you can apply styles to only those
screens that are greater, or smaller, than a certain
width
13. CSS MEDIA QUERIES
• Media queries can be used to interrogate
different properties of the browser and adapt
to changing environments
• These can be efficiently combined with CSS
variables to create responsive web pages
14. CSS MEDIA QUERIES
• Syntax
@media not|only mediatype and (mediafeature and|or|not mediafeature) {
CSS-Code;
}
57. CSS GRID
• The CSS Grid Layout Module offers a grid-
based layout system, with rows and columns,
making it easier to design web pages without
having to use floats and positioning
• We can use display: grid in order to activate a
grid layout
69. IMPORTING CSS FILES
• You can import other CSS files in your current
CSS code by using the @import statement
• You can overwrite imported styles, by
redefining them in your current CSS file
• The import statement runs an additional HTTP
request to download the imported file (speed!)
70. CSS BROWSER SUPPORT
• Each web browser uses a layout engine to
render web pages, and support for CSS
functionality is not consistent between them
• Always check browser compatibility when
adding new styling to your webpage, especially
if this is part of a newer version of CSS (current
version is CSS 4)
• Always check your webpage across all
browsers
71. PRACTICAL EXAMPLE – LOG IN
STYLING
• Create a classical log-in webpage, with the
following elements:
• A “Log in” label
• A “Username” textbox with label, marked as
“required”
• A password box with label, marked as “required”
• A “Log in” button
• A “Forgot password” hyperlink
81. PRACTICAL EXAMPLE – LOG IN
STYLING
Outstanding questions:
• How was the gradient
effect on the buttons
generated?
• How can you change
styling/color when an item
is hovered over?
• How was the “Required”
text changed in the
Orange form?