christmas trees made with html css and js

27
CHRISTMAS TREES WITH HTML, CSS & JS NIAMH FOLEY

Upload: niamh-ni-fhoghlu

Post on 20-Nov-2014

2.540 views

Category:

Education


1 download

DESCRIPTION

Slide show outlineing code and steps to make both a Javacript and CSS Christmas tree

TRANSCRIPT

Page 1: Christmas Trees Made with HTML CSS and JS

CHRISTMAS TREES WITH HTML, CSS & JS

NIAMH FOLEY

Page 2: Christmas Trees Made with HTML CSS and JS

WHAT WE ARE GOING TO CREATE

HTML5 Tree with decoration HTML + CSS Tree

Page 3: Christmas Trees Made with HTML CSS and JS

HYPER TEXT MARK UP LANGUAGE

Pros• Provides a basic structure for data to be

displayed

• Very easy to pick up and learn

• Mistakes are easily found and fixed

• There are many development environments

Cons• HTML is not dynamic – meaning it has no logic

to it

• No one structure to it

Page 4: Christmas Trees Made with HTML CSS and JS

CASCADING STYLE SHEETS

Pros• Easy to learn

• Used by 99.999% of websites

• Tidy's up HTML makes it “Cleaner”

• Provides the skin to HMTL

Cons• None Its that Good

Page 5: Christmas Trees Made with HTML CSS and JS

JAVASCRIPT

Pros• As close as you can get to coding with out all the

“Messy Stuff” of code

• Safe !! You cannot damage your system as its self contained

• Extremely powerful tool for creating web apps

• Very easy to pick up and learn

Cons• Only works in a browser

• No Development environment

• Debugging is a pain

• Each browser reacts to code differently

• Imagination is your only limit with JS

Page 6: Christmas Trees Made with HTML CSS and JS

HOUSE KEEPING1. Create a Directory called “Christmas Tree”

2. Create a subdirectory called “css”

3. Create a file called “styles.css” and save into css

4. Create a file called “index.htm” and save into the root directory (Christmas Tree)

Keyboard Short cuts

Copy : Ctrl + C

Paste : Ctrl + V

Cut : Ctrl + X

Page 7: Christmas Trees Made with HTML CSS and JS

HTML BOILER PLATE

<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>The HTML, CSS & JS Christmass Trees</title> <link rel="stylesheet" href="css/tree.css"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--></head><body> <canvas id="canvas" width="300" height="300" style="border-style:solid;" ></canvas></body></html>

Use this boiler plate code to begin

Page 8: Christmas Trees Made with HTML CSS and JS

HTTP://BIT.LY/CHRISTMASTREEHTTP://BIT.LY/TREECSSHTTP://BIT.LY/JSTREE

FEAR NOT !!!

Page 9: Christmas Trees Made with HTML CSS and JS

HTML5 + JAVASCRIPT TREE

Page 10: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

<body onload="draw();">

<script type="text/javascript">

// JS goes in here

</script>Setup

Page 11: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

function draw() {

var canvas = document.getElementById('canvas');

if (canvas.getContext){

var ctx = canvas.getContext('2d');

// more code goes here !!

}

}

Step 1 - Beginning Code

Page 12: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

ctx.beginPath();

ctx.moveTo(150, 10); // starting point

ctx.lineTo(x, y);

ctx.lineTo(x, y);

ctx.fillStyle = “USE HEX CODE” ;

ctx.fill();

Step 2 – The Triangle

Page 13: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY ctx.fillStyle = “USE HEX CODE”;

ctx.fillRect (x,y,w,h); // (x,y,width,height)Step 3 – The base

Page 14: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

ctx.beginPath();

ctx.arc(140, 75, 10, 0, Math.PI*2, true);

// Uses trig to create circle

ctx.closePath();

ctx.fillStyle = " USE HEX CODE ";

ctx.fill();

Step 4 - Decorations

Page 15: Christmas Trees Made with HTML CSS and JS

TEST IT !! Fingers Crossed it Worked

Page 16: Christmas Trees Made with HTML CSS and JS

HTML + CSS TREE

Page 17: Christmas Trees Made with HTML CSS and JS

SETUP

1. Use HTML Boiler Plate

2. Create a styles.css file in the css directory

Page 18: Christmas Trees Made with HTML CSS and JS

HTML BOILER PLATE<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>The HTML, CSS & JS Christmass Trees</title> <link rel="stylesheet" href="css/tree.css"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--></head><body> <canvas id="canvas" width="300" height="300" style="border-style:dotted solid;" ></canvas></body></html>

Page 19: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

<div class="logo">

<div id="tree"></div>

<div id="trunk">

<div id="left-branch"></div>

<div id="right-bottom-branch"></div>

<div id="right-top-branch"></div>

</div>

</div>

Adding the HTML scaffolding

Page 20: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

.logo{

height: 200px; width: 160px;

margin: 150px auto;

position: relative;

}

Logo Class

Page 21: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

#tree {

border-bottom: 200px solid #//Putt Colour in here;

border-left: 80px solid transparent;

border-right: 80px solid transparent;

position: absolute; top: 0; left: 0;

height: 0; width: 0;

}

Tree Identifier

Page 22: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

#trunk{

height: 85px; width: 16px;

background: #3b543f;

position: absolute; left: 72px; bottom: -20px;

}

Trunk Identifier

Page 23: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

#left-branch{

background: #//Put Colour in here;

height: 30px; width: 6px;

position: absolute; left: -10px; top: 15px;

transform: rotate(-50deg);

-webkit-transform: rotate(-50deg);

-moz-transform: rotate(-50deg);

-ms-transform: rotate(-50deg);

-o-transform: rotate(-50deg);

}

Branch Identifiers

Left

Page 24: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

#right-bottom-branch{

background: #//Put Colour in here;

height: 50px; width: 6px;

position: absolute; top: 15px; left: 23px;

transform: rotate(50deg);

-webkit-transform: rotate(50deg);

-moz-transform: rotate(50deg);

-ms-transform: rotate(50deg);

-o-transform: rotate(50deg);

}

Branch Identifier

Right bottom

Page 25: Christmas Trees Made with HTML CSS and JS

FUNCTIONALITY

#right-top-branch{

background: #//Put Colour in here;

height: 27px; width: 6px;

position: absolute; top: 2px; left: 20px;

transform: rotate(50deg);

-webkit-transform: rotate(50deg);

-moz-transform: rotate(50deg);

-ms-transform: rotate(50deg);

-o-transform: rotate(50deg);

}

Branch Identifier

Right Top

Page 26: Christmas Trees Made with HTML CSS and JS

TEST IT !! Fingers Crossed it Worked

Page 27: Christmas Trees Made with HTML CSS and JS