Github and Website Workshop/three-column-section: Difference between revisions

From OpenHatch wiki
Content added Content deleted
imported>Auria
(Created page with "Welcome to Challenge 9 of the [https://openhatch.org/wiki/Github_and_Website_Workshop Github and Website Workshop] - creating a section with three cells Text is often organiz...")
 
imported>Auria
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 2: Line 2:


Text is often organized in columns to create the illusion of sub-sections
Text is often organized in columns to create the illusion of sub-sections

(insert image here)


The goal of this challenge is to create a section with three cells.
The goal of this challenge is to create a section with three cells.

[[File:GH-Website-Mockup1.png]]


==HTML==
==HTML==

Like the navigation bar, we want the content to appear on the same line (instead of being stacked on top of each other).

Therefore, we will utilize “display: inline-block”


<tt><section id="fun-facts"></tt> will house the entire section
<tt><section id="fun-facts"></tt> will house the entire section
Line 22: Line 18:
* We will use <tt><nowiki><div class=”item-text”></nowiki></tt> to create padding between the cells
* We will use <tt><nowiki><div class=”item-text”></nowiki></tt> to create padding between the cells


Challenge: why can’t we simply use <nowiki><tt><div class=”an-item”></tt></nowiki>?
'''Question''': why can’t we simply use <tt><nowiki><div class=”an-item”></nowiki></tt>?
Hint: we are setting the width of each cell to be 33% (⅓ of 100%), what would padding do to the width?
* Hint: we are setting the width of each cell to be 33% (⅓ of 100%), what would padding do to the width?


===Challenge: add divs to index.html following the above guidelines===
Reference code:
<section id="fun-facts">
<h1>Fun Facts</h1>
<div class="three-items">
<div class="an-item">
<div class="item-text">
Text here
</div>
</div>
<div class="an-item">
<div class="item-text">
Text here
</div>
</div>
<div class="an-item">
<div class="item-text">
Text here
</div>
</div>
</div>
</section>


[http://pastebin.com/UkBt6ARK Solution code]
CSS


div.three-items {
display: block;
text-align: center;
width: 100%;
}


==CSS==
div.an-item {
display: inline-block;
width: 33%;
}


Like the navigation bar, we want the content to appear on the same line (instead of being stacked on top of each other). Therefore, we will utilize “display: inline-block”
Challenge: creating padding between the cells
Hint: use div#item-text to do so


<code>
Challenge: add images above the text in each cell and make them circular
div.three-items {
Hint: define a class in <img> and use “border-radius: 50%” in the CSS
display: block; /* display block is default for divs - this is the difference between between div and span */
text-align: center;
width: 100%;
}


div.an-item {
display: inline-block; /* this element is block but will be flowed with surrounding content as if it were a single inline box (kind of like span) */
width: 33%;
}
</code>


'''Challenge''': creating padding between the cells
Save the changes and reload index.html
* Hint: use div#item-text to do so
When you’re satisfied, commit and push the changes

'''Challenge''': add images above the text in each cell and make them circular
* Hint: define a class in <img> and use “border-radius: 50%” in the CSS




Save the changes and reload index.html. When you’re satisfied, [https://openhatch.org/wiki/Github_and_Website_Workshop/git-commit-changes commit and push the changes].
Save the changes and reload index.html. When you’re satisfied, [https://openhatch.org/wiki/Github_and_Website_Workshop/git-commit-changes commit and push the changes].

[https://openhatch.org/wiki/Github_and_Website_Workshop/new-page-grid Next: Challenge 10]

Latest revision as of 15:13, 6 March 2015

Welcome to Challenge 9 of the Github and Website Workshop - creating a section with three cells

Text is often organized in columns to create the illusion of sub-sections

The goal of this challenge is to create a section with three cells.

HTML

<section id="fun-facts"> will house the entire section

<div class=”three-items”> will house the row the contains the three cells

<div class=”an-item”> will house an individual cell

<div class=”item-text”> will house the text for an individual cell

  • We will use <div class=”item-text”> to create padding between the cells

Question: why can’t we simply use <div class=”an-item”>?

  • Hint: we are setting the width of each cell to be 33% (⅓ of 100%), what would padding do to the width?

Challenge: add divs to index.html following the above guidelines

Solution code


CSS

Like the navigation bar, we want the content to appear on the same line (instead of being stacked on top of each other). Therefore, we will utilize “display: inline-block”

div.three-items {
   display: block; /* display block is default for divs - this is the difference between between div and span */
   text-align: center;
   width: 100%;
}
div.an-item {
   display: inline-block; /* this element is block but will be flowed with surrounding content as if it were a single inline box (kind of like span) */
   width: 33%;
}

Challenge: creating padding between the cells

  • Hint: use div#item-text to do so

Challenge: add images above the text in each cell and make them circular

  • Hint: define a class in <img> and use “border-radius: 50%” in the CSS


Save the changes and reload index.html. When you’re satisfied, commit and push the changes.

Next: Challenge 10