SlideShare a Scribd company logo
1 of 27
CHRISTMAS TREES
WITH HTML, CSS & JS
NIAMH FOLEY
WHAT WE ARE GOING TO CREATE
HTML5 Tree with decoration

HTML + CSS Tree
HYPER TEXT MARK UP LANGUAGE
Pros

Cons

• Provides a basic structure for data to be
displayed

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

• Very easy to pick up and learn

• No one structure to it

• Mistakes are easily found and fixed
• There are many development environments
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
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
HOUSE KEEPING
1. 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
HTML BOILER PLATE
Use this boiler plate code to begin

<!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>
HTTP://BIT.LY/CHRISTMASTREE
HTTP://BIT.LY/TREECSS
HTTP://BIT.LY/JSTREE
FEAR NOT !!!
HTML5 + JAVASCRIPT TREE
<body onload="draw();">
<script type="text/javascript">

FUNCTIONALITY

// JS goes in here

Setup

</script>
function draw() {
var canvas = document.getElementById('canvas');

FUNCTIONALITY
Step 1 - Beginning Code

if (canvas.getContext){
var ctx = canvas.getContext('2d');
// more code goes here !!

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

FUNCTIONALITY
Step 2 – The Triangle

ctx.lineTo(x, y);

ctx.lineTo(x, y);
ctx.fillStyle = “USE HEX CODE” ;
ctx.fill();
FUNCTIONALITY
Step 3 – The base

ctx.fillStyle = “USE HEX CODE”;
ctx.fillRect (x,y,w,h); // (x,y,width,height)
ctx.beginPath();
ctx.arc(140, 75, 10, 0, Math.PI*2, true);

FUNCTIONALITY
Step 4 - Decorations

// Uses trig to create circle

ctx.closePath();
ctx.fillStyle = " USE HEX CODE ";
ctx.fill();
TEST IT !!
Fingers Crossed it Worked
HTML + CSS TREE
SETUP

1. Use HTML Boiler Plate
2. Create a styles.css file in the css directory
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>
<div class="logo">
<div id="tree"></div>
<div id="trunk">

FUNCTIONALITY
Adding the HTML scaffolding

<div id="left-branch"></div>
<div id="right-bottom-branch"></div>
<div id="right-top-branch"></div>
</div>
</div>
.logo{

height: 200px; width: 160px;

FUNCTIONALITY

margin: 150px auto;

Logo Class

position: relative;
}
#tree {

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

FUNCTIONALITY

border-right: 80px solid transparent;

Tree Identifier

position: absolute; top: 0; left: 0;
height: 0; width: 0;
}
#trunk{

height: 85px; width: 16px;

FUNCTIONALITY

background: #3b543f;

Trunk Identifier

position: absolute; left: 72px; bottom: -20px;
}
#left-branch{
background: #//Put Colour in here;
height: 30px; width: 6px;

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

FUNCTIONALITY

transform: rotate(-50deg);

Branch Identifiers

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

Left

-moz-transform: rotate(-50deg);
-ms-transform: rotate(-50deg);
-o-transform: rotate(-50deg);
}
#right-bottom-branch{
background: #//Put Colour in here;
height: 50px; width: 6px;
position: absolute; top: 15px; left: 23px;

FUNCTIONALITY

transform: rotate(50deg);

Branch Identifier

-webkit-transform: rotate(50deg);

Right bottom

-moz-transform: rotate(50deg);

-ms-transform: rotate(50deg);
-o-transform: rotate(50deg);
}
#right-top-branch{
background: #//Put Colour in here;
height: 27px; width: 6px;
position: absolute; top: 2px; left: 20px;

FUNCTIONALITY

transform: rotate(50deg);

Branch Identifier

-webkit-transform: rotate(50deg);

Right Top

-moz-transform: rotate(50deg);

-ms-transform: rotate(50deg);
-o-transform: rotate(50deg);
}
TEST IT !!
Fingers Crossed it Worked
Christmas Trees Made with HTML CSS and JS

More Related Content

What's hot

Excel lesson formulas and functions
Excel lesson formulas and functionsExcel lesson formulas and functions
Excel lesson formulas and functions
wildman099
 
Microsoft excel training module
Microsoft excel training moduleMicrosoft excel training module
Microsoft excel training module
Jeff Piontek
 
Lesson 4 Advanced Spreadsheet Skills/Post-Test
Lesson 4 Advanced Spreadsheet Skills/Post-TestLesson 4 Advanced Spreadsheet Skills/Post-Test
Lesson 4 Advanced Spreadsheet Skills/Post-Test
daki01
 

What's hot (20)

filipino piling larang -akademikong sulatin
filipino piling larang -akademikong sulatinfilipino piling larang -akademikong sulatin
filipino piling larang -akademikong sulatin
 
An Abandoned Mansion in Oton
An Abandoned Mansion in OtonAn Abandoned Mansion in Oton
An Abandoned Mansion in Oton
 
WHAT IS ABM (accountancy business and management)?
WHAT IS ABM (accountancy business and management)?WHAT IS ABM (accountancy business and management)?
WHAT IS ABM (accountancy business and management)?
 
Basic Web Design Principles and Elements
Basic Web Design Principles and ElementsBasic Web Design Principles and Elements
Basic Web Design Principles and Elements
 
Excel lesson formulas and functions
Excel lesson formulas and functionsExcel lesson formulas and functions
Excel lesson formulas and functions
 
Word 2007-Mail Merge 1- Use Mail Merge For Mass Mailings
Word 2007-Mail Merge 1- Use Mail Merge For Mass MailingsWord 2007-Mail Merge 1- Use Mail Merge For Mass Mailings
Word 2007-Mail Merge 1- Use Mail Merge For Mass Mailings
 
Art Promotion and Preservation.pptx
Art Promotion and Preservation.pptxArt Promotion and Preservation.pptx
Art Promotion and Preservation.pptx
 
L9 Collaborative ICT Development.pptx
L9 Collaborative ICT Development.pptxL9 Collaborative ICT Development.pptx
L9 Collaborative ICT Development.pptx
 
Rubrics in personal development
Rubrics in personal developmentRubrics in personal development
Rubrics in personal development
 
Microsoft excel training module
Microsoft excel training moduleMicrosoft excel training module
Microsoft excel training module
 
Lesson 4 Advanced Spreadsheet Skills/Post-Test
Lesson 4 Advanced Spreadsheet Skills/Post-TestLesson 4 Advanced Spreadsheet Skills/Post-Test
Lesson 4 Advanced Spreadsheet Skills/Post-Test
 
Online Search and Research Skills - Empowerment Technologies
Online Search and Research Skills - Empowerment TechnologiesOnline Search and Research Skills - Empowerment Technologies
Online Search and Research Skills - Empowerment Technologies
 
Empowerment Technologies - Module 6
Empowerment Technologies - Module 6Empowerment Technologies - Module 6
Empowerment Technologies - Module 6
 
Contemporary Filipino Painters
Contemporary Filipino PaintersContemporary Filipino Painters
Contemporary Filipino Painters
 
National Artists of the Philippines.pptx
National Artists of the Philippines.pptxNational Artists of the Philippines.pptx
National Artists of the Philippines.pptx
 
FABM2- Module 2-SCI.pptx
FABM2- Module 2-SCI.pptxFABM2- Module 2-SCI.pptx
FABM2- Module 2-SCI.pptx
 
National artist
National artistNational artist
National artist
 
Ppda lecture 1 introduction to art and the human body
Ppda lecture 1 introduction to art and the human bodyPpda lecture 1 introduction to art and the human body
Ppda lecture 1 introduction to art and the human body
 
CNHS_thesis.docx.pdf
CNHS_thesis.docx.pdfCNHS_thesis.docx.pdf
CNHS_thesis.docx.pdf
 
Advanced Word Processing Skills - Empowerment Technologies
Advanced Word Processing Skills - Empowerment TechnologiesAdvanced Word Processing Skills - Empowerment Technologies
Advanced Word Processing Skills - Empowerment Technologies
 

Viewers also liked

Media as mirror vs. prosthesis
Media as mirror vs. prosthesisMedia as mirror vs. prosthesis
Media as mirror vs. prosthesis
Himanshu Bansal
 
Lifestyle unit 9
Lifestyle unit 9Lifestyle unit 9
Lifestyle unit 9
Les Davy
 
решение основной проблемы Agile (scrum) проектов в контексте ba
решение основной проблемы Agile (scrum) проектов в контексте baрешение основной проблемы Agile (scrum) проектов в контексте ba
решение основной проблемы Agile (scrum) проектов в контексте ba
ISsoft
 
Images and Tables in HTML
Images and Tables in HTMLImages and Tables in HTML
Images and Tables in HTML
Aarti P
 

Viewers also liked (20)

HTML lets get creative!!
HTML lets get creative!!HTML lets get creative!!
HTML lets get creative!!
 
Media as mirror vs. prosthesis
Media as mirror vs. prosthesisMedia as mirror vs. prosthesis
Media as mirror vs. prosthesis
 
HTML and UML
HTML and  UMLHTML and  UML
HTML and UML
 
HMTL putting it all to gether
HMTL putting it all to getherHMTL putting it all to gether
HMTL putting it all to gether
 
HTML page layout II
HTML page layout IIHTML page layout II
HTML page layout II
 
Lifestyle unit 9
Lifestyle unit 9Lifestyle unit 9
Lifestyle unit 9
 
Php Security
Php SecurityPhp Security
Php Security
 
Введение в веб-проектирование
Введение в веб-проектированиеВведение в веб-проектирование
Введение в веб-проектирование
 
Таблицы Html
Таблицы HtmlТаблицы Html
Таблицы Html
 
решение основной проблемы Agile (scrum) проектов в контексте ba
решение основной проблемы Agile (scrum) проектов в контексте baрешение основной проблемы Agile (scrum) проектов в контексте ba
решение основной проблемы Agile (scrum) проектов в контексте ba
 
WordPress as Rapid Prototyping Tool
WordPress as Rapid Prototyping ToolWordPress as Rapid Prototyping Tool
WordPress as Rapid Prototyping Tool
 
Пингвины из калининграда
Пингвины из калининградаПингвины из калининграда
Пингвины из калининграда
 
Custom Post Type and Taxonomies in WordPress 3.x
Custom Post Type and Taxonomies in WordPress 3.xCustom Post Type and Taxonomies in WordPress 3.x
Custom Post Type and Taxonomies in WordPress 3.x
 
Show vs. Tell in UX Design (Front in Amsterdam)
Show vs. Tell in UX Design (Front in Amsterdam)Show vs. Tell in UX Design (Front in Amsterdam)
Show vs. Tell in UX Design (Front in Amsterdam)
 
How Joomla Works
How Joomla WorksHow Joomla Works
How Joomla Works
 
17. основы css (cascading style sheets)
17. основы css (cascading style sheets)17. основы css (cascading style sheets)
17. основы css (cascading style sheets)
 
6. таблицы и другие теги html
6. таблицы и другие теги html6. таблицы и другие теги html
6. таблицы и другие теги html
 
Organisation and navigation
Organisation and navigationOrganisation and navigation
Organisation and navigation
 
Images and Tables in HTML
Images and Tables in HTMLImages and Tables in HTML
Images and Tables in HTML
 
Getting Started With Php Frameworks @BCP5
Getting Started With Php Frameworks @BCP5Getting Started With Php Frameworks @BCP5
Getting Started With Php Frameworks @BCP5
 

Similar to Christmas Trees Made with HTML CSS and JS

Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web Performance
Adam Lu
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
Justin Cataldo
 

Similar to Christmas Trees Made with HTML CSS and JS (20)

About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
 
HTML 5 - Overview
HTML 5 - OverviewHTML 5 - Overview
HTML 5 - Overview
 
Introduction to Web Technologies PPT.pptx
Introduction to Web Technologies PPT.pptxIntroduction to Web Technologies PPT.pptx
Introduction to Web Technologies PPT.pptx
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
Html5 & less css
Html5 & less cssHtml5 & less css
Html5 & less css
 
Html5
Html5Html5
Html5
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web Performance
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
Claim Academy Intro to Programming
Claim Academy Intro to ProgrammingClaim Academy Intro to Programming
Claim Academy Intro to Programming
 
Html5
Html5Html5
Html5
 
Html5 - Novas Tags na Prática!
Html5 - Novas Tags na Prática!Html5 - Novas Tags na Prática!
Html5 - Novas Tags na Prática!
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
 
jQuery
jQueryjQuery
jQuery
 
New Elements & Features in HTML5
New Elements & Features in HTML5New Elements & Features in HTML5
New Elements & Features in HTML5
 
Shifting Gears
Shifting GearsShifting Gears
Shifting Gears
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
Mobile native-hacks
Mobile native-hacksMobile native-hacks
Mobile native-hacks
 
Ext JS Introduction
Ext JS IntroductionExt JS Introduction
Ext JS Introduction
 

More from Niamh Foley (7)

HTML Cheat Sheet
HTML Cheat SheetHTML Cheat Sheet
HTML Cheat Sheet
 
HTML coding and syntax
HTML coding and syntaxHTML coding and syntax
HTML coding and syntax
 
HTML an introduction
HTML an introductionHTML an introduction
HTML an introduction
 
HTML an introduction
HTML an introductionHTML an introduction
HTML an introduction
 
File management 101
File management 101File management 101
File management 101
 
Basic tags
Basic tagsBasic tags
Basic tags
 
Niamh foley html module discriptor
Niamh foley html module discriptorNiamh foley html module discriptor
Niamh foley html module discriptor
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

Christmas Trees Made with HTML CSS and JS

  • 1. CHRISTMAS TREES WITH HTML, CSS & JS NIAMH FOLEY
  • 2. WHAT WE ARE GOING TO CREATE HTML5 Tree with decoration HTML + CSS Tree
  • 3. HYPER TEXT MARK UP LANGUAGE Pros Cons • Provides a basic structure for data to be displayed • HTML is not dynamic – meaning it has no logic to it • Very easy to pick up and learn • No one structure to it • Mistakes are easily found and fixed • There are many development environments
  • 4. 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
  • 5. 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
  • 6. HOUSE KEEPING 1. 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
  • 7. HTML BOILER PLATE Use this boiler plate code to begin <!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>
  • 11. function draw() { var canvas = document.getElementById('canvas'); FUNCTIONALITY Step 1 - Beginning Code if (canvas.getContext){ var ctx = canvas.getContext('2d'); // more code goes here !! } }
  • 12. ctx.beginPath(); ctx.moveTo(150, 10); // starting point FUNCTIONALITY Step 2 – The Triangle ctx.lineTo(x, y); ctx.lineTo(x, y); ctx.fillStyle = “USE HEX CODE” ; ctx.fill();
  • 13. FUNCTIONALITY Step 3 – The base ctx.fillStyle = “USE HEX CODE”; ctx.fillRect (x,y,w,h); // (x,y,width,height)
  • 14. ctx.beginPath(); ctx.arc(140, 75, 10, 0, Math.PI*2, true); FUNCTIONALITY Step 4 - Decorations // Uses trig to create circle ctx.closePath(); ctx.fillStyle = " USE HEX CODE "; ctx.fill();
  • 15. TEST IT !! Fingers Crossed it Worked
  • 16. HTML + CSS TREE
  • 17. SETUP 1. Use HTML Boiler Plate 2. Create a styles.css file in the css directory
  • 18. 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>
  • 19. <div class="logo"> <div id="tree"></div> <div id="trunk"> FUNCTIONALITY Adding the HTML scaffolding <div id="left-branch"></div> <div id="right-bottom-branch"></div> <div id="right-top-branch"></div> </div> </div>
  • 20. .logo{ height: 200px; width: 160px; FUNCTIONALITY margin: 150px auto; Logo Class position: relative; }
  • 21. #tree { border-bottom: 200px solid #//Putt Colour in here; border-left: 80px solid transparent; FUNCTIONALITY border-right: 80px solid transparent; Tree Identifier position: absolute; top: 0; left: 0; height: 0; width: 0; }
  • 22. #trunk{ height: 85px; width: 16px; FUNCTIONALITY background: #3b543f; Trunk Identifier position: absolute; left: 72px; bottom: -20px; }
  • 23. #left-branch{ background: #//Put Colour in here; height: 30px; width: 6px; position: absolute; left: -10px; top: 15px; FUNCTIONALITY transform: rotate(-50deg); Branch Identifiers -webkit-transform: rotate(-50deg); Left -moz-transform: rotate(-50deg); -ms-transform: rotate(-50deg); -o-transform: rotate(-50deg); }
  • 24. #right-bottom-branch{ background: #//Put Colour in here; height: 50px; width: 6px; position: absolute; top: 15px; left: 23px; FUNCTIONALITY transform: rotate(50deg); Branch Identifier -webkit-transform: rotate(50deg); Right bottom -moz-transform: rotate(50deg); -ms-transform: rotate(50deg); -o-transform: rotate(50deg); }
  • 25. #right-top-branch{ background: #//Put Colour in here; height: 27px; width: 6px; position: absolute; top: 2px; left: 20px; FUNCTIONALITY transform: rotate(50deg); Branch Identifier -webkit-transform: rotate(50deg); Right Top -moz-transform: rotate(50deg); -ms-transform: rotate(50deg); -o-transform: rotate(50deg); }
  • 26. TEST IT !! Fingers Crossed it Worked