SlideShare a Scribd company logo
1 of 26
Download to read offline
How To Make A Recipe Book
Flipped Coding Workbook
Make your HTML file.
Create a new file named "recipe-book.html" and start with your basic
HTML code.
Now start filling in the head element.
This is where the behind the scenes stuff happens.
You will link to your CSS and JavaScript files here, but don't worry
because you will be making those files later on.
First you will use the link element to make a reference to the style sheet
you will make.
The link element uses the href attribute to tell the browser where it
should look for styles.
Give the href attribute a value of "recipe-styles.css" and you're done.
Next you will use the script element to reference the JavaScript file you'll
be making later.
The script element uses the src attribute to tell the browser where to find
the JavaScript it will run on the page.
Make your HTML file.
Just as a side note, you can have multiple link and script elements that
reference different files.
Now you can turn your attention to the body element.
This is where everything that you see on a screen goes.
Just to see how the recipes will look, make a simple one first.
In the example, there are only four elements that make up a recipe card.
You will have a div element that acts as a container for the recipe details.
Then you will have three div elements inside of the container that hold the
title of the recipe, the ingredients, and the cooking instructions.
If you notice, all of the current elements have different class attributes.
The reason you want to use classes here instead of ids is because you will
be reusing styles to make all of the recipe cards look the same.
Here you'll see my famous (very basic, but delicious) taco recipe as an
example.
Feel free to use any other title, ingredient list, or instructions to replace
my recipe.
Make your HTML file.
You are about halfway done with the HTML file now.
The next element you're going to make is another div, but when we get to
the style sheet and the JavaScript, you'll see how to make a div behave like
a button.
For now go ahead and create another div element and give it an id
attribute of "add-recipe-card".
This has an id instead of a class because you will only use this name once
in the entire project.
The last thing you're going to add to your HTML file is a form element that
contains four sub-elements.
You are making this form so that you will be able to add other recipe cards
to your recipe book and you need a place to enter all of the new
information.
Make your HTML file.
Take a note that the form element has a class attribute.
Why do you think it has a class instead of an id?
Think about it for a moment and I'll explain why in the CSS section.
For now, add an input element to inside of the form.
This input is going to be used to get the title of a new recipe.
Give it a type attribute of "text", a name attribute with the value "new-
recipe-title", and a placeholder attribute with some simple instructions of
what should be entered in this field.
Next make a textarea element.
This is where you will be able to write the ingredients you need.
Give the textarea a type of "text", a name of "new-recipe-ingredients", and
a placeholder that tells you to enter the ingredients.
You need one more textarea for the cooking instructions.
So make a new textarea element and give it a type of "text", a name of
"new-recipe-instructions", and a placeholder telling you to enter the
cooking instructions.
The last thing you need to add to this form and to the entire HTML file is a
button.
This button is what you will click after you have entered all of your recipe
information.
All you have to do here is give it a type of "button" and write some text
between the button tags.
Here's what your code should look like.
Make your HTML file.
Now that you have finished the HTML file, open it in your browser.
It should look something like this.
Make your HTML file.
It's ugly right now, but once you finish your style sheet it will be a lot
easier to read and work with.
Just to make sure that all of your code is right, here is what the entire
HTML file should look like.
Make your CSS file.
You are officially a third of the way through you recipe app.
It doesn’t do anything yet, but it will soon enough.
Now it's time to style it.
Make a new file and save it as "recipe-styles.css".
Start by adding styles to the div with the "add-recipe-card" id.
When you are targeting an element by an id attribute, always include a
pound sign (#) in front of the id name.
That's how this CSS selector works.
After you have the selector, you can start adding style properties.
In this case, you'll be adding seven properties.
You want the button to be noticeable so that means you want to position
it in a good spot and give it the size and color it needs to stand out.
First you'll add a background color.
Give it the hexadecimal value you see in the following code.
Next you'll want to change the color of the font.
You do that by using the color property.
Give it the hexadecimal value you see next to it in the following code.
Now you want to adjust the font size so that it's readable and it draws
your attention to it.
The value it has makes it 1.3 times bigger than the normal font size.
Make your CSS file.
Then you'll add some padding to the button so that it really looks like a
button.
Padding is responsible for the spacing inside of an element.
Then you get to the positioning part.
The fixed value is going to hold that button in the same place regardless of
whether you scroll down the page or not.
You'll always be able to see it.
To put the button in the right position, you'll use the right and top
properties.
This dictates how far from those edges the button should be.
This is what your button styles should look like.
Now you're ready for a few selectors with less properties.
To really make that div element act like a button, it needs to change when
you hover over it.
Make your CSS file.
Have you ever noticed that almost all buttons change colors a little when
you hover over them?
You're going to learn how that works.
You'll use the same id selector that you used before except now you'll add
the pseudo-selector called hover.
Any styles that you put on this selector will only show when you hover
over that div.
To keep the color consistent, you're going to make it fade a little.
There are a few ways to do that, but you'll be using the rgba format.
This will give you the same color with some opacity.
Now you need to set a font type for everything in your recipe book.
To do that, you'll use the font-family property on the body element.
You can type the name of any font you want here, but keep in mind that
font might not be available on every computer.
That's why you use the sans-serif back up. That will let the browser pick a
font similar to yours.
Make your CSS file.
It's time for a bit of explanation.
Remember that class you only used once in the HTML file?
This is what it does.
You set the display property to none so that you can't see the form on the
screen until you click the button.
The reason it was a class instead of an id is because this is a fairly common
style and it's typically used to hide and show multiple elements.
If you haven't seen this before then you're in for a treat.
You can apply the same styles to different elements by using multiple
selectors.
For this recipe app, you want the input and textareas to look about the
same.
There's no need to add a class to each of them because you can use their
tag names as selectors.
You can apply the same styles to different elements by joining the element
names together with a comma because that's how the CSS syntax works.
You'll set the display property to block so that the elements are stacked
on top of each other instead of sitting side by side.
Make your CSS file.
Then you'll want to increase the font size to make the text you type more
readable.
After that you'll want to put a margin on the bottom of each element to
give them some spacing or else they will blend together.
Lastly you need to give them a width.
The 30% value you see isn't anything special.
It's just the number I chose because it looked good to me.
The recipe-card class is the last big thing you need to style.
Give it a border so that it will have some definition.
Otherwise it looks like some text floating on the screen.
You've seen how the font-size property works, but this kind of margin
value is new.
When you see a margin property set like this, the first value is going to be
the margin for the top and bottom of the element and the second value is
going to be the margin for the left and right of the element.
You'll see the auto value used a lot for centering elements in the screen.
Make your CSS file.
The last two properties on this selector should look familiar.
Remember, the padding property sets how much space is inside of the
element and the width determines how much horizontal space an element
takes up on the screen.
There are only two more sets of styles you need to add before your style
sheet is finished.
You're going to use the same set of styles for both the recipe ingredients
and instructions.
So chain those class selectors together and add a bottom margin to them.
Make your CSS file.
The last styles that you will be adding are for the recipe title.
You want the title to stand out so that you can quickly skim through your
recipes to find the one you need.
To do that you will use some of the properties you've seen already to
increase the font size and add a bottom margin.
Once you've finished writing all of the styles, you're recipe book should
look something like this.
Make your CSS file.
Here's the full CSS code as well.
That's all!
Your CSS file is finished!
Make your CSS file.
Make your JavaScript file.
You're on the last part of this tutorial.
This is where the real programming happens and this is where you make
your recipe book work.
This code is going to be made of three main functions, but first make a
new file called "recipe-functions.js".
The first function is responsible for making the code run once the page
has been loaded.
Inside of this function you are going to make a variable that captures the
"add-recipe-card" element using the id name for in the querySelector
method.
Next you'll add an event listener that runs a function called
addRecipeCard every time that element is clicked.
After that you'll create another variable that holds the form element.
Then you can start making the addRecipeCard function.
First you'll declare the function and then you'll start adding things to it.
Make your JavaScript file.
Inside of the function, go ahead and remove the "hidden" class from the
form element.
This will show your form on the screen after you click the "add-recipe-
card" button.
Next you'll make a variable to hold the button element.
Then you'll use that variable to add an event listener to it.
Whenever you click the button that's in the form it will called the
makeNewRecipeCard function that you are about to write.
Now you can declare this new function called makeNewRecipeCard and
start adding stuff inside of it.
The first thing you want to do is make a new variable that will hold a blank
recipe card.
That's what the createElement method does.
Then you'll want to add the right class name to that new recipe card so
that the styles will style consistent.
Make your JavaScript file.
Next you'll want to get the values you entered into the form.
To do that you have to get the value of the element by using the value
property.
You'll put those values into variables that you can use later.
You're almost there!
Now you have to make the elements for your new recipe title, ingredients,
and instructions.
To do that, you'll need to use the insertAdjacentHTML method.
This will allow you to use a template literal string to make the HTML
element itself and to include the values you got from the input and
textareas.
All of these elements become part of the newRecipeCard you made
earlier.
Make your JavaScript file.
It's almost over now.
You only have a few lines of code left to write.
Now that you have built a completely new recipe card, you need to
include it on the page.
To do that, you need to use the insertBefore method.
This will keep your cards in the order you put them in.
Then to finish up, you'll add the "hidden" class back to the form so that it's
not lingering with the other recipes and you want to reset that form so
that you don't have old values there when you go to add a new recipe.
That's it!
You are finally finished with your recipe book.
When you click the button to in the upper right corner you should see this.
Make your JavaScript file.
After you finish adding your recipe details and you click the "Add Recipe"
button in the form, you should see something like this.
Make your JavaScript file.
Make your JavaScript file.
Here’s the full JavaScript code as well.
Make your JavaScript file.
Call To Action
I hope that you enjoyed making your own recipe
book!
Now go add a new feature to your book.
Make it include pictures or something like that.
A quick note: if you leave the page your recipe book is
on, your recipes ARE NOT SAVED.
It takes a database of some sort to do that and a
different programming language.
If you have questions about this code or you need
some help, come to the Flipped Coding membership.
You'll be able to get direct feedback for your code and
you'll be able to ask a private community your specific
questions.
Go check it out right now!
www.flippedcoding.com/course-sign-up
Notes

More Related Content

What's hot

Basic CSS concepts by naveen kumar veligeti
Basic CSS concepts by naveen kumar veligetiBasic CSS concepts by naveen kumar veligeti
Basic CSS concepts by naveen kumar veligetiNaveen Kumar Veligeti
 
HTML Basics 2 workshop
HTML Basics 2 workshopHTML Basics 2 workshop
HTML Basics 2 workshopJohn Allan
 
Basic HTML Tutorial For Beginners
Basic HTML Tutorial For BeginnersBasic HTML Tutorial For Beginners
Basic HTML Tutorial For BeginnersDHTMLExtreme
 
Divs and Links Styles
Divs and Links StylesDivs and Links Styles
Divs and Links StylesDaniel Downs
 
Visualforce css developer guide(by forcetree.com)
Visualforce css developer guide(by forcetree.com)Visualforce css developer guide(by forcetree.com)
Visualforce css developer guide(by forcetree.com)Edwin Vijay R
 
HTML Basics 1 workshop
HTML Basics 1 workshopHTML Basics 1 workshop
HTML Basics 1 workshopJohn Allan
 
Build an App with JavaScript and jQuery - LA - July 18
Build an App with JavaScript and jQuery - LA - July 18Build an App with JavaScript and jQuery - LA - July 18
Build an App with JavaScript and jQuery - LA - July 18Thinkful
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101Ashraf Hamdy
 
Customizing the Appearance and HTML Output of Visualforce Pages
Customizing the Appearance and HTML Output of VisualforcePages Customizing the Appearance and HTML Output of VisualforcePages
Customizing the Appearance and HTML Output of Visualforce Pages Mohammed Safwat Abu Kwaik
 
Contents page construction
Contents page constructionContents page construction
Contents page constructionMike4231
 
WordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child ThemesWordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child ThemesMichelle Ames
 
bawawjspdx082117
bawawjspdx082117bawawjspdx082117
bawawjspdx082117Thinkful
 
La build your own website september 5
La build your own website september 5La build your own website september 5
La build your own website september 5Thinkful
 
Windows Vista
Windows VistaWindows Vista
Windows Vistacartsh
 
iGoogle Gadgets @ Your Library
iGoogle Gadgets @ Your LibraryiGoogle Gadgets @ Your Library
iGoogle Gadgets @ Your LibraryEdward Metz
 
13- Learn CSS Fundamentals / Specificity
13- Learn CSS Fundamentals / Specificity13- Learn CSS Fundamentals / Specificity
13- Learn CSS Fundamentals / SpecificityIn a Rocket
 

What's hot (20)

Basic CSS concepts by naveen kumar veligeti
Basic CSS concepts by naveen kumar veligetiBasic CSS concepts by naveen kumar veligeti
Basic CSS concepts by naveen kumar veligeti
 
Html5 accessibility
Html5 accessibilityHtml5 accessibility
Html5 accessibility
 
HTML Basics 2 workshop
HTML Basics 2 workshopHTML Basics 2 workshop
HTML Basics 2 workshop
 
TYPO3 Housekeeping
TYPO3 HousekeepingTYPO3 Housekeeping
TYPO3 Housekeeping
 
Basic HTML Tutorial For Beginners
Basic HTML Tutorial For BeginnersBasic HTML Tutorial For Beginners
Basic HTML Tutorial For Beginners
 
Divs and Links Styles
Divs and Links StylesDivs and Links Styles
Divs and Links Styles
 
Html basics
Html basicsHtml basics
Html basics
 
Visualforce css developer guide(by forcetree.com)
Visualforce css developer guide(by forcetree.com)Visualforce css developer guide(by forcetree.com)
Visualforce css developer guide(by forcetree.com)
 
HTML Basics 1 workshop
HTML Basics 1 workshopHTML Basics 1 workshop
HTML Basics 1 workshop
 
Build an App with JavaScript and jQuery - LA - July 18
Build an App with JavaScript and jQuery - LA - July 18Build an App with JavaScript and jQuery - LA - July 18
Build an App with JavaScript and jQuery - LA - July 18
 
Designing for the web - 101
Designing for the web - 101Designing for the web - 101
Designing for the web - 101
 
Customizing the Appearance and HTML Output of Visualforce Pages
Customizing the Appearance and HTML Output of VisualforcePages Customizing the Appearance and HTML Output of VisualforcePages
Customizing the Appearance and HTML Output of Visualforce Pages
 
Contents page construction
Contents page constructionContents page construction
Contents page construction
 
WordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child ThemesWordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child Themes
 
bawawjspdx082117
bawawjspdx082117bawawjspdx082117
bawawjspdx082117
 
Seoptimizing
SeoptimizingSeoptimizing
Seoptimizing
 
La build your own website september 5
La build your own website september 5La build your own website september 5
La build your own website september 5
 
Windows Vista
Windows VistaWindows Vista
Windows Vista
 
iGoogle Gadgets @ Your Library
iGoogle Gadgets @ Your LibraryiGoogle Gadgets @ Your Library
iGoogle Gadgets @ Your Library
 
13- Learn CSS Fundamentals / Specificity
13- Learn CSS Fundamentals / Specificity13- Learn CSS Fundamentals / Specificity
13- Learn CSS Fundamentals / Specificity
 

Similar to Recipe book flipped-coding

Similar to Recipe book flipped-coding (20)

Customizing Your WordPress Theme Using Firebug and Basic CSS
Customizing Your WordPress Theme Using Firebug and Basic CSSCustomizing Your WordPress Theme Using Firebug and Basic CSS
Customizing Your WordPress Theme Using Firebug and Basic CSS
 
Tfbyoweb.4.9.17
Tfbyoweb.4.9.17Tfbyoweb.4.9.17
Tfbyoweb.4.9.17
 
BYOWHC823
BYOWHC823BYOWHC823
BYOWHC823
 
Basics Of Css And Some Common Mistakes
Basics Of Css And Some Common MistakesBasics Of Css And Some Common Mistakes
Basics Of Css And Some Common Mistakes
 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
 
Using class suffixes
Using class suffixesUsing class suffixes
Using class suffixes
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Html
HtmlHtml
Html
 
Html
HtmlHtml
Html
 
Html n css tutorial
Html n css tutorialHtml n css tutorial
Html n css tutorial
 
HTML Tutorial
HTML TutorialHTML Tutorial
HTML Tutorial
 
CSS Foundations, pt 1
CSS Foundations, pt 1CSS Foundations, pt 1
CSS Foundations, pt 1
 
Presentation 1 [autosaved]
Presentation 1 [autosaved]Presentation 1 [autosaved]
Presentation 1 [autosaved]
 
Tutorial5
Tutorial5Tutorial5
Tutorial5
 
Tutorial5
Tutorial5Tutorial5
Tutorial5
 
Css
CssCss
Css
 
Css introduction
Css introductionCss introduction
Css introduction
 
Sacramento web design
Sacramento web designSacramento web design
Sacramento web design
 
ARTICULOENINGLES
ARTICULOENINGLESARTICULOENINGLES
ARTICULOENINGLES
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
 

Recently uploaded

办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Lucknow
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Excelmac1
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一3sw2qly1
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 

Recently uploaded (20)

办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...
 
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
定制(CC毕业证书)美国美国社区大学毕业证成绩单原版一比一
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 

Recipe book flipped-coding

  • 1. How To Make A Recipe Book Flipped Coding Workbook
  • 2. Make your HTML file. Create a new file named "recipe-book.html" and start with your basic HTML code. Now start filling in the head element. This is where the behind the scenes stuff happens. You will link to your CSS and JavaScript files here, but don't worry because you will be making those files later on. First you will use the link element to make a reference to the style sheet you will make. The link element uses the href attribute to tell the browser where it should look for styles. Give the href attribute a value of "recipe-styles.css" and you're done. Next you will use the script element to reference the JavaScript file you'll be making later. The script element uses the src attribute to tell the browser where to find the JavaScript it will run on the page.
  • 3. Make your HTML file. Just as a side note, you can have multiple link and script elements that reference different files. Now you can turn your attention to the body element. This is where everything that you see on a screen goes. Just to see how the recipes will look, make a simple one first. In the example, there are only four elements that make up a recipe card. You will have a div element that acts as a container for the recipe details. Then you will have three div elements inside of the container that hold the title of the recipe, the ingredients, and the cooking instructions. If you notice, all of the current elements have different class attributes. The reason you want to use classes here instead of ids is because you will be reusing styles to make all of the recipe cards look the same. Here you'll see my famous (very basic, but delicious) taco recipe as an example. Feel free to use any other title, ingredient list, or instructions to replace my recipe.
  • 4. Make your HTML file. You are about halfway done with the HTML file now. The next element you're going to make is another div, but when we get to the style sheet and the JavaScript, you'll see how to make a div behave like a button. For now go ahead and create another div element and give it an id attribute of "add-recipe-card". This has an id instead of a class because you will only use this name once in the entire project. The last thing you're going to add to your HTML file is a form element that contains four sub-elements. You are making this form so that you will be able to add other recipe cards to your recipe book and you need a place to enter all of the new information.
  • 5. Make your HTML file. Take a note that the form element has a class attribute. Why do you think it has a class instead of an id? Think about it for a moment and I'll explain why in the CSS section. For now, add an input element to inside of the form. This input is going to be used to get the title of a new recipe. Give it a type attribute of "text", a name attribute with the value "new- recipe-title", and a placeholder attribute with some simple instructions of what should be entered in this field. Next make a textarea element. This is where you will be able to write the ingredients you need. Give the textarea a type of "text", a name of "new-recipe-ingredients", and a placeholder that tells you to enter the ingredients. You need one more textarea for the cooking instructions. So make a new textarea element and give it a type of "text", a name of "new-recipe-instructions", and a placeholder telling you to enter the cooking instructions. The last thing you need to add to this form and to the entire HTML file is a button. This button is what you will click after you have entered all of your recipe information. All you have to do here is give it a type of "button" and write some text between the button tags. Here's what your code should look like.
  • 6. Make your HTML file. Now that you have finished the HTML file, open it in your browser. It should look something like this.
  • 7. Make your HTML file. It's ugly right now, but once you finish your style sheet it will be a lot easier to read and work with. Just to make sure that all of your code is right, here is what the entire HTML file should look like.
  • 8. Make your CSS file. You are officially a third of the way through you recipe app. It doesn’t do anything yet, but it will soon enough. Now it's time to style it. Make a new file and save it as "recipe-styles.css". Start by adding styles to the div with the "add-recipe-card" id. When you are targeting an element by an id attribute, always include a pound sign (#) in front of the id name. That's how this CSS selector works. After you have the selector, you can start adding style properties. In this case, you'll be adding seven properties. You want the button to be noticeable so that means you want to position it in a good spot and give it the size and color it needs to stand out. First you'll add a background color. Give it the hexadecimal value you see in the following code. Next you'll want to change the color of the font. You do that by using the color property. Give it the hexadecimal value you see next to it in the following code. Now you want to adjust the font size so that it's readable and it draws your attention to it. The value it has makes it 1.3 times bigger than the normal font size.
  • 9. Make your CSS file. Then you'll add some padding to the button so that it really looks like a button. Padding is responsible for the spacing inside of an element. Then you get to the positioning part. The fixed value is going to hold that button in the same place regardless of whether you scroll down the page or not. You'll always be able to see it. To put the button in the right position, you'll use the right and top properties. This dictates how far from those edges the button should be. This is what your button styles should look like. Now you're ready for a few selectors with less properties. To really make that div element act like a button, it needs to change when you hover over it.
  • 10. Make your CSS file. Have you ever noticed that almost all buttons change colors a little when you hover over them? You're going to learn how that works. You'll use the same id selector that you used before except now you'll add the pseudo-selector called hover. Any styles that you put on this selector will only show when you hover over that div. To keep the color consistent, you're going to make it fade a little. There are a few ways to do that, but you'll be using the rgba format. This will give you the same color with some opacity. Now you need to set a font type for everything in your recipe book. To do that, you'll use the font-family property on the body element. You can type the name of any font you want here, but keep in mind that font might not be available on every computer. That's why you use the sans-serif back up. That will let the browser pick a font similar to yours.
  • 11. Make your CSS file. It's time for a bit of explanation. Remember that class you only used once in the HTML file? This is what it does. You set the display property to none so that you can't see the form on the screen until you click the button. The reason it was a class instead of an id is because this is a fairly common style and it's typically used to hide and show multiple elements. If you haven't seen this before then you're in for a treat. You can apply the same styles to different elements by using multiple selectors. For this recipe app, you want the input and textareas to look about the same. There's no need to add a class to each of them because you can use their tag names as selectors. You can apply the same styles to different elements by joining the element names together with a comma because that's how the CSS syntax works. You'll set the display property to block so that the elements are stacked on top of each other instead of sitting side by side.
  • 12. Make your CSS file. Then you'll want to increase the font size to make the text you type more readable. After that you'll want to put a margin on the bottom of each element to give them some spacing or else they will blend together. Lastly you need to give them a width. The 30% value you see isn't anything special. It's just the number I chose because it looked good to me. The recipe-card class is the last big thing you need to style. Give it a border so that it will have some definition. Otherwise it looks like some text floating on the screen. You've seen how the font-size property works, but this kind of margin value is new. When you see a margin property set like this, the first value is going to be the margin for the top and bottom of the element and the second value is going to be the margin for the left and right of the element. You'll see the auto value used a lot for centering elements in the screen.
  • 13. Make your CSS file. The last two properties on this selector should look familiar. Remember, the padding property sets how much space is inside of the element and the width determines how much horizontal space an element takes up on the screen. There are only two more sets of styles you need to add before your style sheet is finished. You're going to use the same set of styles for both the recipe ingredients and instructions. So chain those class selectors together and add a bottom margin to them.
  • 14. Make your CSS file. The last styles that you will be adding are for the recipe title. You want the title to stand out so that you can quickly skim through your recipes to find the one you need. To do that you will use some of the properties you've seen already to increase the font size and add a bottom margin. Once you've finished writing all of the styles, you're recipe book should look something like this.
  • 15. Make your CSS file. Here's the full CSS code as well. That's all! Your CSS file is finished!
  • 16. Make your CSS file.
  • 17. Make your JavaScript file. You're on the last part of this tutorial. This is where the real programming happens and this is where you make your recipe book work. This code is going to be made of three main functions, but first make a new file called "recipe-functions.js". The first function is responsible for making the code run once the page has been loaded. Inside of this function you are going to make a variable that captures the "add-recipe-card" element using the id name for in the querySelector method. Next you'll add an event listener that runs a function called addRecipeCard every time that element is clicked. After that you'll create another variable that holds the form element. Then you can start making the addRecipeCard function. First you'll declare the function and then you'll start adding things to it.
  • 18. Make your JavaScript file. Inside of the function, go ahead and remove the "hidden" class from the form element. This will show your form on the screen after you click the "add-recipe- card" button. Next you'll make a variable to hold the button element. Then you'll use that variable to add an event listener to it. Whenever you click the button that's in the form it will called the makeNewRecipeCard function that you are about to write. Now you can declare this new function called makeNewRecipeCard and start adding stuff inside of it. The first thing you want to do is make a new variable that will hold a blank recipe card. That's what the createElement method does. Then you'll want to add the right class name to that new recipe card so that the styles will style consistent.
  • 19. Make your JavaScript file. Next you'll want to get the values you entered into the form. To do that you have to get the value of the element by using the value property. You'll put those values into variables that you can use later. You're almost there! Now you have to make the elements for your new recipe title, ingredients, and instructions. To do that, you'll need to use the insertAdjacentHTML method. This will allow you to use a template literal string to make the HTML element itself and to include the values you got from the input and textareas. All of these elements become part of the newRecipeCard you made earlier.
  • 20. Make your JavaScript file. It's almost over now. You only have a few lines of code left to write. Now that you have built a completely new recipe card, you need to include it on the page. To do that, you need to use the insertBefore method. This will keep your cards in the order you put them in. Then to finish up, you'll add the "hidden" class back to the form so that it's not lingering with the other recipes and you want to reset that form so that you don't have old values there when you go to add a new recipe. That's it! You are finally finished with your recipe book. When you click the button to in the upper right corner you should see this.
  • 21. Make your JavaScript file. After you finish adding your recipe details and you click the "Add Recipe" button in the form, you should see something like this.
  • 23. Make your JavaScript file. Here’s the full JavaScript code as well.
  • 25. Call To Action I hope that you enjoyed making your own recipe book! Now go add a new feature to your book. Make it include pictures or something like that. A quick note: if you leave the page your recipe book is on, your recipes ARE NOT SAVED. It takes a database of some sort to do that and a different programming language. If you have questions about this code or you need some help, come to the Flipped Coding membership. You'll be able to get direct feedback for your code and you'll be able to ask a private community your specific questions. Go check it out right now! www.flippedcoding.com/course-sign-up
  • 26. Notes