CSS level 3 & beyond ..
History of CSS
Full CSS described at http://www.w3.org/Style/CSS/specs.en.html
Summary at: http://www.css3.info
Current recommendation: https://www.w3.org/TR/css-2018/
CSS modules (selection)
CSS Selectors (1)
CSS Selectors (2)
CSS Selectors (3)
:current(p) { background : yellow } - selects and colors the paragraph of text that is currently read in a speech rendering of the document
Gradient images - linear
background: linear-gradient([direction], color-stop1, color-stop2,…)
background: linear-repeating-gradient ([direction], color-stop1, color-stop2,…)
Gradient images - radial
background: radial-gradient(<center position> <shape> <size>, color-stop1, color-stop2, …)
background: radial-repeating-gradient(<center position> <shape> <size>, color-stop1, color-stop2, …)
2D Transforms (1)
-> applies a 2D or 3D transformation to an element
2D Transforms (2)
ex.: rotate(45deg);
3D Transforms (1)
3D Transforms (2)
Transitions - properties
Transitions - examples
div {
transition-property: width;
transition-duration: 5s;
}
div:hover { width: 100px }
div {
width: 20px;
transition: width 3s, transform 3s;
}
div:hover {
width: 100px;
transform: rotate(90deg);
}
Animations - properties
Animations - @keyframes
@keyframes name-of-animation {
keyframe-selector {
property: value;
…
property: value;
}
…
keyframe-selector {
property: value;
…
property: value;
}
}
keyframe-selector is either ‘from’ (=0%), ‘to’ (=100%) or a percent of animation
Duration from 0% to 100%.
property is a CSS property.
Animations - example
@keyframes move {
0% { left: 100px; }
40% { left: 130px; }
100% { left: 150px; }
}
div {
animation: move 5s;
}
Multiple columns
Multiple columns - example
div {
column-count : 3;
column-rule-color : black;
column-rule-style : dotted;
column-rule-width : 1px;
}
div {
columns: 40px 2;
}
Borders
create rounded corners; there are two radix values for each corner : top-left, top-right, bottom-right, bottom-left
ex. div { border-radius : 10px 10px 20px 20px / 5px 5px 10px 10px }
adds a inner/outer shadow to a box;
ex. div { box-shadow : 2px 2px 5px #eeffdd }
source=image used for border; slice=4 inward offsets of the border image for top, bottom, left and right sides; width=4 widths of the border image for top, bottom, left and right sides; outset=4 values, the amount the border image extends outside the border of the box
Background and sprites
Text shadow & box-shadow
text-shadow: 2px 2px 4px #ff00dd;� }
div {
box-shadow: 4px 6px 6px -2px #aaaaff;
}
CSS flexbox display
<div class=“flexdiv”>
<div>1</div>
<div>2</div>
</div>
.flexdiv {
display: flex;
flex-direction: column | column-reverse | row | row-reverse;
flex-wrap: nowrap | wrap | wrap-reverse;
justify-content: center | flex-start | flex-end; // align horizontally
align-items: center | flex-start | flex-end; // align vertically
}
More flex..
justify-content: flex-start (left) | flex-end (right) |
center | space-between | space-around |
space-evenly
[space-between/around/evenly regulate space between
flex components]
align-items : flex-start (top) | flex-end (bottom) | center | stretch | baseline
Even more flex ..
CSS Grid
Beyond CSS : CSS preprocessors
CSS preprocessors, example (less)
@font-size: 16px;
.bordered (@width) {
border: @width solid #ddd;
&:hover {
border-color: #999;
}
}
h1 { .bordered(5px);
font-size: @font-size;
}
Responsive web design
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- sets the width of the page to follow the screen width of the device
- sets the initial zoom level to 1 (no zoom)
Responsive web design (2)
Responsive web design (3)
@media only screen and (max-width: 500px) {� #div1 {� width: 100%;� }�}
@media only screen and (min-width: 500px) {� ….
}
@media only screen and (orientation: landscape) {� …
}
Responsive design. Media query example
<style>
body { display: flex; }�#left {width: 25%; background-color: #ff88aa}�#main {width: 75%; background-color: #aa22ff}�
@media screen and (max-width: 800px) {
body { display: flex;
flex-direction: column; }� #left, #main { width: 100%; }�}
</style>
<body>
<section id=“left”> …. </section>
<section id=“main”> …. </section>
</body>
CSS neat typography: web fonts
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family=Jura">
<style>
body {
color: #cfd2da;
font-family: 'Jura', sans-serif;
font-size: 0.9rem;
}
</style>
Neat CSS icons: google icons
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<i class="material-icons" style="font-size:48px;color:red“>folder</i>
<i class="material-icons" style="font-size:48px;color:red“> cloud_upload</i>
Neat CSS icons: fontawesome
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<i class="fa fa-car" style="font-size:60px;color:red;"></i>
More fontawsome ..
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<li><div>
<a href="#" id="1">
<i class="fab fa-html5"></i>
Lab 1 – HTML
</a>
</div></li>
<li><div>
<a href="#" id="2">
<i class="fab fa-css3-alt"></i>
Lab 2 - CSS simple
</a>
</div></li>
...