Professional Documents
Culture Documents
20480
20480
Source order = equal specificity selectors are applied in the order they appear in the stylesheet
2 Creating and Styling HTML Pages
2.1 Creating an HTML5 Page
The visibility property enables you to blank out the selected elements, but leave the
space that they
would take up on the page empty.
The display property enables you to set how to display selected elements on the page.
This includes
hiding the selected elements, or completely removing them from the page.
The position property enables you to set positioning method for the selected elements
are
positioned. The four possible values are static (the default), fixed, absolute, and relative.
The float property enables you to take the selected elements out of the flow of content
and 'float'
them to the left or right of their containing elements.
The overflow property enables you to set what happens when the content of an element
is too big
for the box that contains it.
The box-sizing property enables you to set how the width and height properties apply to
an
element's box model. If set to content-box (the default), they work as described above. If set to
border-box, the width and height apply to the total of content, padding, border and margin
taken
together.
h2.highlight {
height : 100px;
width : 500px;
padding : 10px;
border : 2px dotted blue;
margin : 25px 0 25px 0; /* Could also be written 25px 0
*/
}
padding-top: 10px;
padding-right : 10px;
padding-bottom : 10px;
padding-left : 10px;
border-width: 2px;
border-style: dotted;
border-color: blue;
border-left-style, border-left-width,
border-left-color,
border-right-style, border-right-width
3 Introduction to JavaScript
3.1 Overview of JavaScript
3.2 Introduction to the Document Object Model
3.3 Introduction to jQuery
request.setRequestHeader("Content-Type",
"application/json");
@font-face {
font-family: 'RobotoRegular';
src: url('Roboto-Regular-webfont.eot');
src: url('Roboto-Regular-webfont.eot?#iefix') format('embedded-
opentype'),
url('Roboto-Regular-webfont.woff') format('woff'),
url('Roboto-Regular-webfont.ttf') format('truetype'),
url('Roboto-Regular-webfont.svg#RobotoRegular') format('svg');
}
html {
color : inherit;
background: -ms-linear-gradient(30deg, lightblue, green,
color: currentColor;
yellow);
}
html {
background: -ms-radial-gradient(top right, ellipse, red, blue);
}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model
https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model#Property_inheritance_revisited
function drop(ev)
{
ev.preventDefault();
var data=ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body>
</body>
</html>
HINT: Modernizr
function myStorageCommitCallback( e ) {
alert("Data written to disk");
}
window.addEventListener("storagecommit",
myStorageCommitCallback, true);
Needed:
Internet Options > Caches and databases > Allow
website caches and databases
Storing Structured Data by Using the Indexed Database API var db; // Reference to the database to use
var openRequest = indexedDB.open("contosoDB");
openRequest.onsuccess = function(event) {
db = event.target.result;
};
openRequest.onerror = function(event) {
alert("Error " + event.target.errorCode + " occurred while opening
the database");
};
========================================================================
var attendee = {
id: "1",
name: "Rachel Valdez",
password: "Pa$$w0rd"
};
var attendeeStore = db.createObjectStore("attendees", { keyPath: "id" });
========================================================================
var newAttendee = {
id: "2",
name: "Eric Gruber",
password: "Pa$$w0rd"
};
var addRequest = attendeeStore.add(newAttendee);
addRequest.onsuccess = function(event) {
// Attendee was successfully added
}
addRequest.onerror = function(event) {
// Handle failure
};
========================================================================
var deleteRequest = attendeeStore.delete("1"); // Remove the details for Rachel Valdez
deleteRequest.onsuccess = function(event) {
// Attendee was successfully deleted
MCT USE ONLY. STUDENT USE PROHIBITED
Programming in HTML5 with JavaScript and CSS3 9-9
}
deleteRequest.onerror = function(event) {
// Handle failure
};
========================================================================
var attendee;
var getRequest = attendeeStore.get("2"); // Retrieve the details for Eric Gruber
getRequest.onsuccess = function(event) {
// Attendee details are available in event.target.result
attendee = event.target.result;
}
getRequest.onerror = function() {
// Handle failure
};
You can test for 13 device characteristics in a media query. The All of these characteristics except scan and grid also allow you to
following list summarizes these query for minimum and maximum values as well. For example, you
characteristics. can specify min-width, max-width, min-resolution, max-resolution,
• width, height: The width and height of the viewport (usually the and so on.
browser window).
• device-width, device-height: The width and height of the active
device screen (or paper, if printing).
• orientation: Whether the device is in portrait or landscape mode.
• resolution: The pixel density (in dpi or as a ratio) of the target device.
• aspect-ratio: The width to height ratio of the viewport.
• device-aspect-ratio: The width-to-height ratio of the device screen
(or paper).
• color: The bits per color of the target display.
• color-index: The total number of colors the target device screen can
show.
• monochrome: The bits per pixel in a monochrome frame buffer.
• scan: The scanning method of a TV. Possible values are progressive
and interlace.
• grid: The display type of the output device: grid or bitmap.
Detecting an Older Version of Internet Explorer by Using Conditional <html>
Comments <head>
<link href="styles.css" rel="stylesheet" />
<!--[if IE 8]> <link href="ie8.css" rel="stylesheet" /><![endif]-->
<!--[if lt IE 8]> <link href="ie7.css" rel="stylesheet" /><![endif]-->
<!--[if gte IE 9]> <link href="ie9.css" rel="stylesheet" /><![endif]-->
<!--[if IEMobile7]> <link href="winPhone7.css" rel="stylesheet" /><!
[endif]-->
<!--[if !(IE)]> <link href="otherBrowsers.css" rel="stylesheet" /> <!
[endif]-->
...
</head>
...
</html>
s
Using Gradients and Patterns
<svg xmlns="http://www.w3.org/2000/svg">
<linearGradient x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0.2" stop-color="yellow" />
<stop offset="0.5" stop-color="green" />
<stop offset="1.0" stop-color="red" />
</linearGradient>
</svg>
<svg xmlns="http://www.w3.org/2000/svg">
<radialGradient id="gradient2" fx="0.3" fy="0.3">
<stop offset="0.1" stop-color="yellow" />
<stop offset="0.7" stop-color="red" />
</radialGradient>
</svg>
<svg xmlns="http://www.w3.org/2000/svg">
<pattern patternUnits="userSpaceOnUse" width="100"
height="100">
<image xlink:href="wales.png" x="0" y="0" width="100"
height="100" />
</pattern>
</svg>
<svg xmlns="http://www.w3.org/2000/svg">
<text x="20" y="50"
fill="yellow" stroke="purple" stroke-width="2"
font-size="36" font-family="verdana" font-weight="bold">
Styled text
</text>
</svg>
Text Decorations Text Paths
text-decoration attribute : A <text> element can contain a <textPath> child
Underline element that indicates a path to use as the baseline for
Overline the text when it is displayed on the web page.
line-through
blink
<g> element allows grouping the multiple texts
<svg xmlns="http://www.w3.org/2000/svg" id="textPath">
<path id="wavyPath1"
fill="none" stroke="green" stroke-width="5"
d="M 50 250
C 150 150 250 50 350 150
C 450 250 550 350 650 250
C 750 150 850 150 850 150" />
<text font-size="46" fill="red" font-family="Verdana">
<textPath xlink:href="#wavyPath1">
Mae hen wlad fy nhadau yn annwyl i mi!
</textPath>
</text>
</svg>
Text Spans
A <textSpan> element can contain any number of <tspan>
child elements that partition the text into a
series of discrete sections. Each section can be styled
individually.
<svg xmlns="http://www.w3.org/2000/svg" id="textSpans">
<defs>
<path id="wavyPath2"
d="M 50 250
C 150 150 250 50 350 150
C 450 250 550 350 650 250
C 750 150 850 150 850 150" />
</defs>
<text font-size="46" fill="orange" font-family="Verdana"
stroke="purple">
<textPath xlink:href="#wavyPath2">
<tspan>Cubic equation: 5x</tspan>
<tspan dy="-30" fill="green" font-size="33">3</tspan>
<tspan dy="+30"> + 4x</tspan>
<tspan dy="-30" fill="green" font-size="33">2</tspan>
<tspan dy="+30"> + 6x - 5 = 0</tspan>
</textPath>
</text>
</svg>
Transforming SVG Elements
11.2 Drawing Graphics by Using the Canvas API
Drawing Paths
//>>>>>>>>>>>>>>PAGE>>>>>>>>>>>>>>>>>>>
function replyHandler(event) {
alert("Reply: " + event.data); // Display the reply in an alert
}
function errorHandler(event) {
console.log(event.message);
}
var webWorker;
...
The event object passed to the error handler contains the webWorker = new Worker("processScript.js"); // The web worker
following properties: code is in this file
o message. A human-readable error message. webWorker.addEventListener("message", replyHandler, false);
webWorker.addEventListener("error", errorHandler, false);
o filename. The name of the script file (as a URL) in which the
webWorker.postMessage("Here is some data");
error occurred. ...
o lineno. The line number of the script file where the error
occurred.
The Structure of a Web Worker Web workers have access to the Global object
importScripts("myfunctions.js");
Creating a Shared Web Worker //>>>>>>>>>>WORKER SIDE>>>>>>>>>>>>
function messageHandler(event) {
// Handle messages received on a port
...
}
function connectHandler(event) {
var port = event.ports[0];
port.addEventListener("message" messageHandler, false);
port.start();
}
self.addEventListener("connect", connectHandler, false);