70-480 Flashcards

1
Q

When to use Article over Section or Div

A

Use section when the content requires a heading and the it makes sense together,

Use Article same as section but also when the content makes sense alone without anything else

Use a Div in all other cases when you dont need to group things based on a header etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

name all new 11 HTML 5 elements

A
article
aside
figcaption
footer
header
hgroup
mark
nav
progress
section
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how to know if an element has child nodes

A

document. hasChildNodes()
document. childNodes()
document. firstChild()
document. lastChild()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how to create an element and remove

A
document.createElement('article")
var someElement = document.getElementById('someDiv')
someElement.removeNode(true);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to add a video to html what attributes can you add

A

attributes
src
autoplay - plays after loaded
controls - just include and it will add play control for user
height/width (height=”400”)
loop - add and will loop
poster - when the video is not playing will use the image argument is location

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how do you add multiple formats for the video element and set a default message if none are supported by browser

A

do not add src to video
as a child element of video add

to add a message that it failed

<p> this is not supported></p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are the methods on a video element how to use them

A

methods are play(), pause(), volume, currentTime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how does an audio element work

A

The exact same as a video element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is a canvas element and how to draw to it

A

a canvas element is used to draw graphic UI elements on a screen.

In javascript get the canvas element draw to it by getting the context from it

canvas. getContext(‘2d’);
canvas. fillRect(x,y, width, height)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to make an element full screen size

A

Best in javascript

somelement.width = window.innerWidth

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Methods to draw basic shapes on a canvas

A

Line - someCanvas.beginPath(), then someCanvas.moveTo( x , y)
then someCanvas.lineTo(x , y) - how many pixel it will move to not where it ends
then someCanvas.stroke() actually draws the line

can add css canvas.strokeStyle = “#FFFFFF”

to change a rectangle color
canvas.fillStyle = “rgb(0,0,0)

circle
canvas.arc(x , y , radians or size, start angle *0 or where to start drawing, end angle or how long to go on for Math.PI * 2, draw counter clock wise = false)

always start with beginstroke, made some shape then stroke

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

using canvas how do you do text

A

two steps,
define the font and then do stroke
someCanvas.font = “30px Arial”;
someCanvas.strokeText(‘someText’, X , Y); or fillTetxt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how to do gradient in shape

A

1.first you want to define the gradient there are two types, linear and radial
someCanvas.createLinearGradient( xBegin, yBegin, xEnd, yEnd)
someCanvas.createRadialGradient( xBegin yBegin rBegin, etc)

  1. add colour stops
    between 0 and 1.
    someGradient.addColorStop( 0, “blue);
  2. fill the style with the new gradient obj

someShape.fillStyle(someGradient);
someShape.fillStroke(someGradient);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how to do animations in canvas

A

want to run requestAnimationFrame() over and over and clear the canvas by running clearRect(side of canvas);
redraw objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

in canvas how to make a curve

A

three options
moveTo(x1, y1)
quadradicCurveTo(x2, y2, x3, y3)

moveTo(x1, y1)
bezierCurveTo(x2, y2, x3, y3, x4, y4)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

how to load img into a canvas

A
var img = new Image(  );
img.src = 'someImage.jpg';
img.onload = function ( ) {
  someCanvas.drawImage(img, 0, 0);
  someCanvas.stroke(  );