ICT 10 Reviewer
ICT 10 Reviewer
The CSS transform property specifies the transformational effect you wish to apply to an HTML element.
Syntax:
html-element {
transform: value;
}
The CSS transform property accepts the following values:
inherit: Transforms the element with its parent element's transform value.
initial: Transforms the HTML element with its default transform value.
matrix(): Transforms the element two-dimensionally with a matrix of six values.
matrix3d(): Transforms the HTML element three-dimensionally with a 4x4 matrix of sixteen values.
none: Applies no transformation to the HTML element.
perspective(): Transforms a 3D transformed element with a perspective view.
rotate(): Transforms the element by rotating it two-dimensionally.
rotate3d(): Transforms the element by rotating it three-dimensionally.
rotateX(): Transforms the element by rotating it three-dimensionally along the X-axis.
rotateY(): Transforms the element by rotating it three-dimensionally along the Y-axis.
rotateZ(): Transforms the HTML element by rotating it three-dimensionally along the Z-axis.
scale(): Transforms the element by scaling it two-dimensionally.
scale3d(): Transforms the element by scaling it three-dimensionally.
scaleX(): Transforms the element by scaling it along the X-axis.
scaleY(): Transforms the element by scaling it along the Y-axis.
scaleZ(): Transforms the HTML element by scaling it three-dimensionally along the Z-axis.
skew(): Transforms the element by skewing it two-dimensionally along the X- and Y-axis.
skewX(): Transforms the element by skewing it two-dimensionally along the X-axis.
skewY(): Transforms the element by skewing it two-dimensionally along the Y-axis.
translate(): Transforms the HTML element by translating (moving) it two-dimensionally.
translate3d(): Transforms the element by translating it three-dimensionally.
translateX(): Transforms the element by translating it along the X-axis.
translateY(): Transforms the element by translating it along the Y-axis.
translateZ(): Transforms the element by translating it three-dimensionally along the Z-axis.
Note: The transform property accepts one or more CSS transform functions. For instance, here's a valid
transform declaration:
div {
transform: perspective(370px) scaleZ(5) rotate(17deg);
}
element {
transform: rotate(angle);
}
Note the following:
element {
transform: rotateX(angle);
}
Syntax:
img {
transform: rotateX(0deg);
width: 80%;
}
70-degree rotation
img {
transform: rotateX(70deg);
width: 80%;
}
Syntax:
element {
transform: rotateY(angle);
}
Zero-degree rotation
img {
transform: rotateY(0deg);
width: 80%;
}
What is the CSS rotateZ() Function?
rotateZ() transforms an element by rotating it three-dimensionally around the Z-axis.
element {
transform: rotateZ(angle);
}
CSS rotate functions and CSS rotate property provides two similar ways to specify rotation transformations.
The main differences between the two rotation techniques are as follows:
The CSS rotate property allows rotating an element without using the CSS transform property.
The CSS rotate property's syntax is shorter than its function alternative.
The CSS rotate property saves you from remembering the specific order to position the transform
functions.
Browsers calculate the transform functions' matrix in the order you assigned them to the CSS transform
property—from left to right.
Browsers calculate the transform properties' matrix in the following transformation matrix order:
1. translate
2. rotate
3. scale
70-degree:
img {
rotate: x 70deg; /* Equal to a transform: rotateX(70deg) property */
width: 80%;
}
Syntax:
element {
transform: scale(x, y);
}
Note:
scale(0.3) is equivalent to scale(0.3, 0.3).
The percentage equivalence of scale(0.3) is scale(30%).
How to scale an element non-uniformly along the X- and Y-axis in CSS:
img {
transform: scale(0.3, 65%);
transform-origin: top left;
}
Note:
A scale factor of 1 or 100% tells browsers not to apply any scaling effect on the selected element.
scale(0.3, 1) is equivalent to scaleX(0.3).
Note:
A 100% or 1 scale factor tells browsers not to apply any scaling effect on the selected element.
scale(100%, 0.2) is equivalent to scaleY(0.2).
CSS scale() Function vs. scale Property: What's the Difference?
The CSS scale() function and the CSS scale property provide two similar ways to specify a scale
transformation.
The main differences between the two scaling techniques are as follows:
The CSS scale property allows scaling an element without using the CSS transform property.
The CSS scale property's syntax is shorter than its function alternative.
The CSS scale property saves you from remembering the specific order to position the transform
functions.
Browsers calculate the transform functions' matrix in the order you assigned them to the CSS
transform property—from left to right.
Browsers calculate the transform properties' matrix in the following order:
1. translate
2. rotate
3. scale
Note:
"Transform origin" is the fixed point from which the computer scales an element.
You can define your element's fixed point using the CSS transform-origin property. But the default
is center.
Note:
The scaleZ(number) function is equivalent to scale3d(1, 1, number).
The number argument specifies the element's scaling factor along the z-axis.
Note:
"Transform origin" is the fixed point from which the computer skews an element.
You can define your element's fixed point using the CSS transform-origin property. But the default
is center.
Syntax of the CSS skew() function
skew() accepts two arguments. Here is the syntax:
element {
transform: skew(aX, aY);
}
The length argument specifies the user's distance to the z=0 plane.
A three dimensional Cartesian coordinate system with a red arrow defining the distance between the user and
the z=0 plane
What are CSS Animations?
An animation lets an element gradually change from one style to another. You can change as many CSS
properties you want, as many times as you want. To use CSS animation, you must first specify some keyframes
for the animation. Keyframes hold what styles the element will have at certain times.
The following example binds the "example" animation to the <div> element. The animation will last for 4
seconds, and it will gradually change the background-color of the <div> element from "red" to "yellow":
Example
/* The animation code */
@keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}
Note: The animation-duration property defines how long an animation should take to complete. If the
animation-duration property is not specified, no animation will occur, because the default value is 0s (0
seconds).
In the example above we have specified when the style will change by using the keywords "from" and "to"
(which represents 0% (start) and 100% (complete)).
It is also possible to use percent. By using percent, you can add as many style changes as you like.
The following example will change the background-color of the <div> element when the animation is 25%
complete, 50% complete, and again when the animation is 100% complete:
Example
/* The animation code */
@keyframes example {
0% {background-color: red;}
25% {background-color: yellow;}
50% {background-color: blue;}
100% {background-color: green;}
}
Delay an Animation
The animation-delay property specifies a delay for the start of an animation.
The following example has a 2 seconds delay before starting the animation:
Example
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-delay: 2s;
}
The following example will run the animation in reverse direction (backwards):
Example
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-direction: reverse;
}
ease - Specifies an animation with a slow start, then fast, then end slowly (this is default)
linear - Specifies an animation with the same speed from start to end
ease-in - Specifies an animation with a slow start
ease-out - Specifies an animation with a slow end
ease-in-out - Specifies an animation with a slow start and end
cubic-bezier(n,n,n,n) - Lets you define your own values in a cubic-bezier function
The following example shows some of the different speed curves that can be used:
Example
The animation-fill-mode property specifies a style for the target element when the animation is not playing
(before it starts, after it ends, or both).
none - Default value. Animation will not apply any styles to the element before or after it is executing
forwards - The element will retain the style values that is set by the last keyframe (depends on
animation-direction and animation-iteration-count)
backwards - The element will get the style values that is set by the first keyframe (depends on
animation-direction), and retain this during the animation-delay period
both - The animation will follow the rules for both forwards and backwards, extending the animation
properties in both directions
CSS Animation Properties
The following table lists the @keyframes rule and all the CSS animation properties:
Property Description
@keyframes Specifies the animation code
animation A shorthand property for setting all the animation properties
animation-delay Specifies a delay for the start of an animation
Specifies whether an animation should be played forwards, backwards or in
animation-direction
alternate cycles
animation-duration Specifies how long time an animation should take to complete one cycle
Specifies a style for the element when the animation is not playing (before it
animation-fill-mode
starts, after it ends, or both)
animation-iteration-count Specifies the number of times an animation should be played
animation-name Specifies the name of the @keyframes animation
animation-play-state Specifies whether the animation is running or paused
animation-timing-function Specifies the speed curve of the animation
What is JavaScript??
JavaScript is a programming language that adds interactivity to your website. This happens in games, in
the behavior of responses when buttons are pressed or with data entry on forms; with dynamic styling; with
animation, etc. This article helps you get started with JavaScript and furthers your understanding of what is
possible.
JavaScript is a powerful programming language that can add interactivity to a website. It was invented by
Brendan Eich.
JavaScript is versatile and beginner-friendly. With more experience, you'll be able to create games, animated 2D
and 3D graphics, comprehensive database-driven apps, and much more!
JavaScript itself is relatively compact, yet very flexible. Developers have written a variety of tools on top of the
core JavaScript language, unlocking a vast amount of functionality with minimum effort. These include:
Browser Application Programming Interfaces (APIs) built into web browsers, providing functionality
such as dynamically creating HTML and setting CSS styles; collecting and manipulating a video stream
from a user's webcam, or generating 3D graphics and audio samples.
Third-party APIs that allow developers to incorporate functionality in sites from other content providers,
such as Disqus or Facebook.
Third-party frameworks and libraries that you can apply to HTML to accelerate the work of building sites
and applications.
Example
<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>
You can place any number of scripts in an HTML document. Scripts can be placed in the <body>, or in the
<head> section of an HTML page, or in both.
What is a string?
Strings are for storing text
Strings are written with quotes
Using Quotes
A JavaScript string is zero or more characters written inside quotes.
Example
Example
Example
let text = `He's often called "Johnny"`;
Escape Characters
Because strings must be written within quotes, JavaScript will misunderstand this string:
let text = "We are the so-called "Vikings" from the north.";
The backslash escape character (\) turns special characters into string characters:
Examples
let text = "We are the so-called \"Vikings\" from the north.";
Back-Tics Syntax
Template Strings use back-ticks (``) rather than the quotes ("") to define a string:
Example
Interpolation
Template String provide an easy way to interpolate variables and expressions into strings.
The method is called string interpolation.
${...}
Example