Ruby Monstas Session 25 Agenda Recap Layouts Exercises Recap - - PowerPoint PPT Presentation

ruby monstas
SMART_READER_LITE
LIVE PREVIEW

Ruby Monstas Session 25 Agenda Recap Layouts Exercises Recap - - PowerPoint PPT Presentation

Ruby Monstas Session 25 Agenda Recap Layouts Exercises Recap https://docs.google.com/presentation/d/1rxHrB4wLk7TMMMtIwC9azwNgnYQAFrae620IxjLHygI/edit#slide=id.ge8e058835_0_0 DIV element Text around<div> Outer DIV element


slide-1
SLIDE 1

Ruby Monstas

Session 25

slide-2
SLIDE 2

Agenda

Recap Layouts Exercises

slide-3
SLIDE 3

https://docs.google.com/presentation/d/1rxHrB4wLk7TMMMtIwC9azwNgnYQAFrae620IxjLHygI/edit#slide=id.ge8e058835_0_0

Recap

slide-4
SLIDE 4

Text around<div> Outer DIV element <div>Inner DIV element</div> I will use the whole width of the site. </div>the DIV element

DIV element

This is a so-called block-level element. Because it breaks the flow of the elements into blocks. There are others: <h1>, <p>, <form> and so on

slide-5
SLIDE 5

This is a <span>S</span>pan elment

SPAN element

This is a so-called inline element. Because it flows inline with all other elements. There are others: <a>, <i>, <b>, <strong> and so on

slide-6
SLIDE 6

A simple layout example

<!DOCTYPE HTML PUBLIC "- //W3C//DTD HTML 4.01//EN" "http://www.w3.

  • rg/TR/html4/strict.dtd">

<html> <body> <div class="header"> <h1>Header</h1> </div> <div class="sidebar"> <h2>Sidebar</h2> </div> <div class="content"> <h2>Content</h2> </div> <div class="footer"> <h1>Footer</h1> </div> </body> </html>

slide-7
SLIDE 7

CSS

.header, .footer { width: 720px; } .sidebar { float: left; height: 50%; width: 220px; } .content { float: left; height: 50%; width: 488px; } .footer { clear: both; }

slide-8
SLIDE 8

HTML5: other elements

An article with a title and text

<article> <h2>Article title</h2> <p>Article text</p> </article> <main> <article> ... </article> <article> ... </article> </main>

Main content

<audio controls> <source src="foo.mp3" type="audio/mpeg"> <source src="foo.ogg" type="audio/ogg"> No support for audio </audio> <video controls> <source src="foo.mp3" type="video/mpeg"> <source src="foo.ogg" type="video/ogg"> No support for video </video>

Embed audio & video

slide-9
SLIDE 9

Layouts

slide-10
SLIDE 10

Layouts

What if we have a web app that always has the same structure with a certain part that is dynamic?

slide-11
SLIDE 11

Layouts

<!doctype html> <html lang="en"> <head> <title>Home page</title> <link rel="stylesheet" href="/css/style.css"> </head> <body> <header> <h1>Welcome to our webpage!</h1> </header> <nav> <!-- navigation --> </nav> <main> <h3>Welcome to our home page!</h3> We are Shirley, Ines and Peter! </main> <footer> <!-- footer --> </footer> </body> </html>

slide-12
SLIDE 12

Layouts

<!doctype html> <html lang="en"> <head> <title>Home page</title> <link rel="stylesheet" href="/css/style.css"> </head> <body> <header> <h1>Welcome to our webpage!</h1> </header> <nav> <!-- navigation --> </nav> <main> <%= yield %> </main> <footer> <!-- footer --> </footer> </body> </html>

<h3>Welcome to our home page!</h3> We are Shirley, Ines and Peter!

slide-13
SLIDE 13

Layouts

<!doctype html> <html lang="en"> <head> <title>Home page</title> <link rel="stylesheet" href=" /css/style.css"> </head> <body> <header> <h1>Welcome to our webpage!</h1> </header> <nav> <!-- navigation --> </nav> <main> <%= yield %> </main> <footer> <!-- footer --> </footer> </body> </html>

<h3>Welcome to our home page!</h3> We are Shirley, Ines and Peter!

slide-14
SLIDE 14

Layouts

# app.rb get '/page' do erb :template1 end # views/layout.erb <!doctype html> <html lang="en"> [...] <body> <header></header> <nav></nav> <main> <%= yield %> </main> <footer></footer> </body> </html> # views/template1.erb <h3>Welcome to our home page!</h3> We are Shirley, Ines and Peter!

slide-15
SLIDE 15

Layouts: Conclusion

The layout is the starting point for rendering a

  • template. In it, you will find a yield block that

actually renders the template you specify. The layout is therefore static and the template that is yielded is your dynamic part.

slide-16
SLIDE 16

Your feedback, please?

http://goo.gl/forms/rUrZqOPNq6 (Session 24)

slide-17
SLIDE 17

Time to practice