HTML5 & CSS3 The Complete Manual 2014
HTML5 & CSS3 The Complete Manual 2014
HTML5
& CSS3
The Complete Manual
WorldMags.net
WorldMags.net
WorldMags.net
Welcome to
HTML5
& CSS3
The Complete Manual
WorldMags.net
WorldMags.net
WorldMags.net
WorldMags.net
HTML5
& CSS3
Publishing Director
Aaron Asadi
Head of Design
Ross Andrews
Production Editor
Jen Neal
Senior Art Editor
Greg Whitaker
Designer
Perry Wardell-Wicks
Photographer
James Sheppard
Printed by
William Gibbons, 26 Planetary Road, Willenhall, West Midlands, WV13 3XT
Distributed in the UK, Eire & the Rest of the World by
Marketforce, Blue Fin Building, 110 Southwark Street, London, SE1 0SU
Tel 0203 148 3300, www.marketforce.co.uk
Distributed in Australia by
Network Services (a division of Bauer Media Group), Level 21 Civic Tower, 66-68 Goulburn Street, Sydney, New South
Wales 2000, Australia, Tel +61 2 8667 5288
Disclaimer
The publisher cannot accept responsibility for any unsolicited material lost or damaged in the post. All text and layout is
the copyright of Imagine Publishing Ltd. Nothing in this bookazine may be reproduced in whole or part without the written
permission of the publisher. All copyrights are recognised and used specifically for the purpose of criticism and review.
Although the bookazine has endeavoured to ensure all information is correct at time of print, prices and availability
may change. This bookazine is fully independent and not affiliated in any way with the companies mentioned herein.
HTML5 & CSS3 The Complete Manual 2014 Imagine Publishing Ltd
ISBN 9781910439418
Part of the
bookazine series
WorldMags.net
WorldMags.net
Contents
What you can find inside the bookazine
Style. CSS
Introducing HTML
Introducing CSS
08
An introduction
to HTML
Get to know HTML5
30
An introduction to CSS
Customise with CSS
40
18
HTML glossary
Learn the basic terms
20
22
23
52
Add a background
image
Add photos and images
56
Style a two-column
layout
Create your own layout
60
Create a header
Code yourself a header
Code a link
Add links to your site
42
64
Create a list
Use <ul> and <ol> tags
Create a sidebar
Add a sidebar to your site
44
68
46
72
48
50
Format images
using CSS
Edit where your images
sit on the page
24
26
Create a three-column
layout
Make a different layout
WorldMags.net
WorldMags.net
Create
your ow
websiten
Responsive design
74
82
Introduction to
Responsive Web Design
Understand what makes
a responsive design
Reference
124 Useful resources
Find everything you
need online
Bootstrap
Responsive design
made easy
112 Techniques for creating
responsive typography
Get to know online font
systems
94
Build a custom
Foundation template
Make your own
responsive design
WorldMags.net
An introduction to HTML
WorldMags.net
Introducing HTML
WorldMags.net
An introduction to HTML
Introducing HTML
WorldMags.net
An introduction to HTML
HyperText Markup Language, more commonly know as HTML, is the basic
building block of the web. It provides the structure, content and connection
between pages, allowing web designers to create interactive experiences.
Easy to learn, it offers limitless possibilities
The majority of web pages are made up of one or more files that
are downloaded to a computer, which in turn are interpreted by a
web browser and finally rendered out to screen. At its simplest, a
web page is a plain text file that contains special instructions about
what kind of content is contained within. These instructions are
written in HTML the language used on the world wide web.
HTML, or HyperText Markup Language to give it the full name,
is the core building block of a web page. HTML is a markup-based,
human-readable language thats designed to be simple to write,
and easy to understand. A markup language is one where bits
of data are literally marked as being of a particular type. So, for
example, a piece of data that you want to render as a paragraph
would be marked up with a paragraph marker.
Marking up
Markers are referred to as tags, and they have less-than and greaterthan symbols around them. This paragraph would be marked
up with a <p> tag at the start to denote a paragraph, and a
matching </p> tag at the end to signify the end of the paragraph.
HTML offers many tags for marking up content, and browsers are
programmed to interpret these tags, formatting the contents of
each tag according to a set of preset rules. This allows the <strong>
tag to render text in bold, and the <em> (for emphasis) tag to
render in italics. One of the major benefits of this system of marking
up content is that its easy to read you dont need any special
software to either write or read HTML documents, as theyre just
plain text. This makes it easy to create a functioning web page using
nothing more complex than a text editor.
9
WorldMags.net
An introduction to HTML
WorldMags.net
Introducing HTML
10
WorldMags.net
An introduction to HTML
Introducing HTML
WorldMags.net
What is HTML5?
The first requirement of any WordPress installation is the
need for web space. There are thousands of web hosting
companies who will happily supply space for a small
fee. However, to determine what sort of web hosting
package is needed the user needs to decide how much
web space is needed and how much traffic is expected.
Users can get 200MB of web space and gigabytes of
traffic for a very small fee. But if more space is likely to be
needed, ie a photo blog, go for more. Dont worry too
much about traffic to start with. New sites are not likely
to get huge amounts of traffic immediately and this can
be changed at a later date very quickly and easily.
A small UK company that provides cheap and efficient
hosting is Z-Host (www.z-host.co.uk). It provides
packages from as little as 15 a year (100MB of web
space and 10GB of monthly traffic), perfect for first time
bloggers. Alternatively, choose 1GB of web space and
40GB of monthly traffic for 60 a year. At the other end
of the scale there is a popular choice with web designer
Media Temple (www.mediatemple.net). This offers
11
WorldMags.net
An introduction to HTML
WorldMags.net
Introducing HTML
12
WorldMags.net
An introduction to HTML
Introducing HTML
WorldMags.net
page. If it finds any files called in, the browser will send a message
back to the web server asking for those files. The final result you see
in your web browser window may be the result of more than 20
individual files, brought together by the web browser and rendered
as a single web page!
13
WorldMags.net
An introduction to HTML
WorldMags.net
Introducing HTML
and make some decisions about what content to show. This might
be as simple as including your name at the top of the page when
youre logged in, or as complex as a fully loaded e-commerce web
store, but all these server-side languages output the same final
result plain HTML. Its important that the web works this way, as
every web browser only has to support one kind of page structural
language, which makes it easier for both web designers and
browser vendors, not to mention for users of the web who know
that all they need to access any website is a web browser and an
internet connection.
14
WorldMags.net
An introduction to HTML
Introducing HTML
WorldMags.net
WorldMags.net
An introduction to HTML
WorldMags.net
Introducing HTML
WorldMags.net
An introduction to HTML
Introducing HTML
WorldMags.net
is already partially implemented in browsers, but other elements
of the language are still being discussed, and theres a good
probability that well see further enhancements in the coming
years such as the ability to specify different resolution images
to be downloaded to desktop computers from those sent to
mobile devices.
Theres been an explosion in smartphone use over the past few
years which has led increasingly to the web being accessed on
the move. These devices have a different screen orientation to the
traditional computer, often have less bandwidth and computing
power, but expect to have a fantastic browsing experience. The
HTML language, through HTML5, is already adapting to meet this
challenge, but as the specification matures you can expect to see
further enhancements with this usage scenario in mind. Its an
exciting time to be a web designer!
17
WorldMags.net
HTML glossary
WorldMags.net
Introducing HTML
HTML glossary
We demystify the definition of the most popular HTML jargon
a
The a tag defines a hyperlink, which
is used to link to another web page.
The <a> tag is typically coupled with
the href attribute which will include
the links destination. For example, <a
href=about.html>link text</a>
aside
This is a tag that was introduced in
HTML5 and refers to content that is an
aside to the main content. The content
in the aside tag should be relevant to
its surrounding content.
audio
The <audio> tag allows for the
inclusion of audio files which can be
read directly by the browser without
the need for a plug-in. Between the
audio tags will be the source od the
audio and any related attributes
body
class
form
div
head
footer
header
br
Br is short for break, or more
specifically line breaks. It is an empty
tag which means it isnt a set of tags
just a single tag. It is used to split long
headlines or long sentences.
canvas
The <canvas> tag is a container where
the necessary code is placed to show
the graphics created by the code. The
18
WorldMags.net
HTML glossary
Introducing HTML
WorldMags.net
The header is typically at the top of
the page and includes elements that
will typically be seen on every page eg
the site title, logo and navigation. For a
tutorial on how to create your header,
go to page 60.
html
nav
img
Img is short for image and defines
where an image will go in a web page.
The img tag is typically paired with src,
which shows the source of the image
and alt. Alt text is what will show in the
browser if the image is not available.
li
The li tag is sort for list. These are
found inside the ul (unordered) or ol
p
This is the HTML tag for paragraph.
This works exactly as a paragraph
would in a book. The paragraph of
text would be surrounded by an
opening and closing set of tags eg
<p></p>.
script
Web pages often include code
beyond HTML and CSS that add
dynamic elements. A simple example
is Google Analytics code and other
code written in JavaScript. The code is
stored inside a set of <script> tags to
help identify the code.
section
table
tag
The term tag refers to all the elements
of the HTML specification. The HTML
language is made up of tags that
are contained in a set of brackets
eg <body>.
title
The title tag is stored inside the head
tag and determines the title of the
page. This title will appear in the
title bar or tab in a web browser. It
is important that the title is concise
and informative as it will be read by
the user and search engines. Do not
include notes within the tag as this will
also show in your title.
ul
Lists are an integral part of web pages
and there are several options for
creating lists. ul is short for unordered
list which means the list is bullet
pointed by default. The alternative
option is ol, ordered list, which adds
numbers or letters eg a,b,c
video
The <video> tag is a set of tags,
which will contain any related video
information. For example, a basic
version would contain width and
height attributes along with the
source of the video.
19
WorldMags.net
Introducing HTML
Header tag
The header differs from the head, as its
contained within the body of the HTML
page, meaning it gets displayed in the
browser. The header usually contains
company insignia, navigation and
possibly an introductory image
Footer
The footer tag denotes an element
that usually goes at the bottom of
the content, and contains items such
as author, contact info, telephone
numbers etc
Div tag
A div is used to
group content
together, in this
case we use it
to display our
content and
sidebar. Divs can
be nested within
each other and
can have IDs and
classes applied to
them so they can
be identified
20
WorldMags.net
01
04
06
001
002
003
004
005
006
007
008
009
010
011
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
02
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My Example Page</title>
</head>
<body>
<header>
</header>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My Example Page<title>
</head>
</html>
03
001
002
003
004
005
006
007
008
009
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My Example Page</title>
</head>
<body>
</body>
</body>
05
When starting
out in web design
its important to
remember to
open and then
close tags
21
WorldMags.net
Code a link
WorldMags.net
Introducing HTML
Code a link
Adding in links to other pages is a key part of web design
While links may seem like a simple element to add to a webpage, they
are the key building blocks of the entire internet. Similar to pages within
a book, separate webpages within a website help to break up content
by topic or purpose. Then, by adding in a navigation bar, it means that
visitors will be able to quickly between content.
Links are also one of the most important elements that Google and other search engines use to find
and index your site. The kind of content that you link out to, and the kind of content contained within
sites that link to your pages, are vital in informing the search engine on how to categorise your site for its
search results.
This tutorial will take you through adding in links leading to other pages in your website, and how to
link out to other peoples sites. Once you have added some links, your site can start to function how its
intended to, with visitors being able to view all the content contained with ease.
Internal links
01
03
05
Href
04
02
22
WorldMags.net
Unordered list
Nested lists
01
03
02
001 <ul>
002 <li> </li>
</ul>
<li> Tea </li>
<li>Coffee</li>
</ul>
<ul>
<li> Tea </li>
<ul>
<li>Breakfast</li>
<li>Earl Grey</li>
<li>Coffee</li>
<ul>
<li>Latte</li>
</ul>
</ul>
Ordered lists
04
Definition lists
05
001 <dl>
002 <dt>Snowboard</dt>
003 <dd>- Great for freestyle tricks
</dd>
004 <dt>Cross Country Skis</dt>
005 <dd>- Ideal for exploring on
</dd>
006 </dl>
007
23
WorldMags.net
Introducing HTML
Adding an ID
01
02
03
001 <div>
002 This is where you will add your
div content.
003 </div>
WorldMags.net
Nesting divs
04
05
Div classes
Classes are widely used in web
development to allow CSS styles to
be associated with elements within
your HTML page
There is no limit
on how many
divs you have
within a page and
most webpages
you visit online will
contain many
IDs
Indenting divs
Code highlighting
25
WorldMags.net
Introducing HTML
26
WorldMags.net
01
Add a title
02
04
to
<head>
<title>
3 Column Layout
</title>
05
06
03
WorldMags.net
Introducing HTML
Adding comments
07
The container
08
Nav tag
10
001 <body>
002 <div id="container">
003 </div>
001
002
003
004
The header
<header>
<nav>
</nav>
</header>
Navigation items
09
11
First column
12
28
WorldMags.net
13
001 <footer>
002 Footer
003 </footer>
Metadata (optional)
16
Third column
14
001
002
003
004
005
006
007
008
009
<div id="sidebar"></div>
Column 1
</div>
<div id="col2">
Column 2
</div>
<div id="sidebar">
Sidebar
</div>
Stopping Google
indexing (optional)
17
15
18
29
WorldMags.net
Introducing CSS
An introduction to CSS
WorldMags.net
Style. CSS
ANDROID LANDSCAPE 320 X 240
30
WorldMags.net
An introduction to CSS
Introducing CSS
WorldMags.net
An introduction to CSS
If HTML provides the structure for a website, CSS provides the form. This is the
language that will make your site stand out
WorldMags.net
Introducing CSS
An introduction to CSS
WorldMags.net
CSS syntax
Just like HTML, CSS is
designed to be humanreadable in its raw form.
English keywords are used
with a simple syntax to
Recent versions of web browsers have vastly improved their implementation of CSS standards
32
WorldMags.net
An introduction to CSS
Introducing CSS
WorldMags.net
CSS3 opens
the web up
to more users
by allowing
individual
stylesheets
on pages
33
WorldMags.net
Introducing CSS
An introduction to CSS
WorldMags.net
describe a list of rules, style
properties and style values.
Each rule in a stylesheet is
defined by means of a
selector, which identifies the
HTML elements the rule
should apply to. Within the
rule, a series of properties and
values are defined so that the
visual characteristics for an
element are built up property
by property. Lets take a quick
look at an example:
h1
font-family: arial, helvetica,
sans-serif;
font-weight: bold;font-size: 18pt;
color:
red;
margin: 10px;
}
More complicated
selectors
In the previous example we
used a simple selector to
establish which elements
the rule should apply to.
Selectors can be nested so
that only specific elements
have the rule applied. An
example might look like the
code that follows:
#content article h1 {
color: blue;
}
34
WorldMags.net
An introduction to CSS
Introducing CSS
WorldMags.net
different rules, and using
specificity and priority its
possible to style a document
with a few SS rules.
Different ways to
load a style
There are three different
ways a style can be applied
to an HTML element. The first
is through an external file
that is loaded into the HTML
document in the <head>
section. The second is to
include a <style> declaration
in the <head> section of the
document, writing your rules
and properties directly inside
the <style> area, and the third
is directly onto an element
using the style attribute. The
latter is referred to as an
inline style.
When calculating the style
properties of an element,
CSS is loaded first from any
external files and applied,
then from the <head> section
of the page, and finally from
any inline styles. Where the
same property is set by more
than one of these three
methods, they apply in the
order as described above.
Positioning
elements
One of the most common
areas of CSS that new
designers struggle to grasp
35
WorldMags.net
Introducing CSS
An introduction to CSS
WorldMags.net
positioning, and especially
float, works.
History and
potential hiccups
By now youre starting to see
the value and potential of CSS,
but its not all as perfect as it
might at first seem. There are
a number of problems that
web designers have to
overcome when using CSS to
style their web pages, and to
36
WorldMags.net
An introduction to CSS
Introducing CSS
WorldMags.net
quickly became
unmanageable, especially
when a web site had lots of
pages. Something as simple as
changing the font a website
used might have taken days to
change, working through
each HTML page in the
website and changing
references from one font
to another.
As a consequence, the W3C
quickly realised that content
should be separate from
presentation, and developed
CSS. CSS1 debuted alongside
HTML4 in 1996, but it wasnt
until some years later that web
browser vendors had
managed to fully implement
the language. In the
meantime, a newer version of
CSS had been created in 1998,
and Netscape and Internet
Explorer version 6 had both
partially implemented CSS2.
As well as the slow
implementation, from the
start there were issues with
the way the CSS specification
had been written, leaving
room for individual
interpretation over what each
part of the specification
meant. This resulted in
Internet Explorer rendering
styles in one way, while the
other popular browser of the
day, Netscape, rendered
differently. As well as
The arrival of
HTML5
As the web has matured, so
have the technologies used to
create it and CSS is no
different. HTML is now just
about at version 5, and CSS3
first came into existence at the
beginning of the century. Its
only in the last couple of years
that either technology has
started to be properly
implemented by browser
vendors however, and the
combination of HTML version
5, CSS version 3 and JavaScript
is often referred to collectively
as HTML5 (erroneously it must
be said!).
As mobile devices have
become increasingly popular,
WorldMags.net
Introducing CSS
An introduction to CSS
WorldMags.net
driving the desire for access
to the web on the move,
and across different screen
sizes, so the browser vendors
have been coaxed into
accelerating their
implementations. This has
provided quite a relief to web
designers who only a year ago
were still implementing
workarounds for Internet
Explorer version 6 a
decade-old piece of software!
Differences of
opinion
Despite the recent strides
towards adoption of CSS3, and
the retirement of Internet
Explorer 6 by Microsoft, there
continues to be quite a lot of
differences between the way
different browsers render CSS.
The most common issue
today is where browsers
implement CSS properties
that havent yet been fully
38
WorldMags.net
An introduction to CSS
Introducing CSS
WorldMags.net
<above> CSS allows websites to be tailored according the device upon which the website is accessed
specification property,
while the others are the
early implementations by
Safari and Chrome, Firefox,
Internet Explorer, and
Opera respectively.
Vendor prefixes are the
subject of much debate
currently as theyve become
more prevalent in recent
years as vendors rush to
outdo each other in their
CSS implementations. For
WorldMags.net
Introducing CSS
Styling with CSS
WorldMags.net
border
The border property, as its name
suggest adds a border to the
associated element. Borders can be
added to all sides of an element or a
specific element such as the top, right,
left or bottom. There are several styles
eg solid, dotted etc and the option to
chose a width.
box-shadow
The box-shadow property allows
for the implementation of multiple
drop shadows on box elements, ie
div elements. It can specify values for
color, size, blur and offset. Text-shadow
uses the same principles but applies
the drop shadows to text.
font-family
height
This is as simple as the name
suggests. The height of an element is
determined by the height property.
This can be a fixed height using pixels
or a flexible height using percentages.
letter-spacing
line-height
Line height is the space between the
lines in text. The line-height property
can use a fixed value with pixels or
alternatively use a number value eg
float
The float property is used to position
an element specifically within
margin
Margins help create space between
content. When adding a 5px margin to
an element it will create a 5px space all
around the element. Margins can be
separated so it is only applied to one
part of an element eg margin-top.
max-height
The max-height property ensures that
an element does not exceed a specific
height. It is often used in conjunction
with max-width, which ensures that
an element doesnt exceed a specific
width. Both properties are typically
Margins help
create space
between content
40
WorldMags.net
text-decoration
The text-decoration property specifies
what can be added to text. You can
add under- and overlines and a strike
through to your text.
value
<above> The width and height property determine how every element on a page is sized
position
overflow
property
width
padding
selector
z-index
syntax
To understand CSS you need to
understand the syntax that is used. CSS
is made up of three parts the selector,
property and value. Typically written
as follows:
001 selector {property: value}
text-align
<above> The spacing between lines of text can
be adjusted with line-height making the text
more legible
41
WorldMags.net
Introducing CSS
Centre your page
WorldMags.net
Set the
margins
Without margins
the page content
is displayed on
the left. You can
manually set them
by entering the
number of pixels,
but a good option is
to set them to auto
to centre the page
Borders or
borderless?
This page has
borders, but they
are optional and
leaving out these
parameters will
remove them.
Its your choice.
Padding, just
above, is used for
extra spacing, but
it isnt needed
42
WorldMags.net
01
04
001 div#wrapper {
002
width: 80%;
003 }
02
05
03
001 div#wrapper {
002
width: 750px;
003 }
001 div#wrapper {
002
width: 80%;
003
margin-left: auto;
004
margin-right: auto;
005 }
Browser compatibility
07
06
WorldMags.net
Introducing CSS
Define body text and heading styles
WorldMags.net
Heading
style
Style other
headings
This is an h1
heading, the
largest that is
available, so we
have made it big
and bold. The font
has been set to
Arial and the size is
set to 30 pixels
Italic text
Keep it simple
Although there
are lots of CSS
parameters that
you can set, you
dont always need
to set them all.
This is a minimal
definition for the
text that sets only
what is needed
44
WorldMags.net
03
Pick a font
01
001
002
003
004
005
006
p {
font-family: Verdana, sans-serif;
font-size: 14px;
font style: normal;
font-weight: normal;
}
001 p {
002 font-family: Verdana;
003 }
Define a class
Select a family
02
04
p.normal {
font-family: Verdana, sans-serif;
font-size: 14px;
font-style: normal;
font-weight: normal;
}
p.italictext {
font-family: Verdana, sans-serif;
font-size: 14px;
font-style: italic;
font-weight: normal;
}
p.boldtext {
font-family: Verdana, sans-serif;
font-size: 14px;
font-style:normal;
font-weight: bold;
}
05
06
45
WorldMags.net
h1 {
font-family: Arial;
font-size: 30px;
font-weight: bold;
margin-bottom:-10px;
}
h2 {
font-family: Arial;
font-size: 20px;
font-weight: bold;
margin-bottom:-10px;
}
Introducing CSS
Style your lists to stand out
WorldMags.net
Customise
your lists
Create a class
01
WorldMags.net
Boxed lists
02
001 p. ul{
002
font-family: Verdana;
003
padding: 10px;
004
font-size: 14px;
005 }
Choose a background
05
001
Inside vs outside
03
001
002
003 }
padding: 10px;
margin: 0px;
06
04
background-color: #ffd0d0; }
Add a border
07
001
002
003 }
border-style: dotted;
border-width: 2px;
08
001
002
003 }
border-width: 2px;
border-color: #880000;
list-style-position: inside;
DIY bullets
09
WorldMags.net
Introducing CSS
Turn lists into navigation bars
WorldMags.net
48
WorldMags.net
01
<ul id="navbar"
<li><a href="index.html">Home</a></li>
<li><a href="news.html">News</a></li>
<li><a href="walks.html">Walks</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="about.html">About</a></li>
</ul>
04
Make it plain
02
001
002
003
004
005
#navbar {
list-style-type: none;
margin: 0px;
padding: 0px;
}
001 #navbar li a {
002 display: block;
003 width: 140px;
004 }
05
Floating elements
03
06
WorldMags.net
Introducing CSS
Format images using CSS
WorldMags.net
WorldMags.net
Build a class
01
03
05
001 img.picright {
02
04
06
51
WorldMags.net
Introducing CSS
Add a background image
WorldMags.net
Background
wrapper colour
If no background colour
is set for the wrapper, the
background colour of the page
will show through. Its up to you
whether you set a #wrapper
background colour
52
WorldMags.net
Impressive backgrounds
A background wrapper
Modify the wrapper
03
Pick a colour
01
As well as inserting an
acceptable number of
hyperlinks, you can also flag up certain
content. Place words and rogue
websites, IP addresses and emails in
this box and any posts containing
such content will immediately be
placed in the moderation queue
where you can assess whether or
not to allow it to be published on
your site. If your banned words form
part of larger words, they too will be
picked up.
001 div#wrapper {
002 width: 750px;
003 padding: 0px;
004 margin-left: auto;
005 margin-right: auto;
006 }
05
001 div#wrapper {
002 background-image:url('back2.jpg');
003 width: 750px;
004 padding: 0px;
005 border: 2px;
006 border-style: solid;
007 border-color: #006600;
008 margin-left: auto;
009 margin-right: auto;
010 }
04
Use a photo
02
06
001 p, ul {
002 font-family: Verdana;
003 font-size: 14px;
004 color: white;
005 }
001
002
003
004
005
body {
background-color: rgb (128,128, 128);
background-image:url('back1.jpg');
}
53
WorldMags.net
Introducing CSS
Add a background image
WorldMags.net
Horizontal gradients
Use smaller images
07
09
11
Tile it across
Create a gradient
08
10
001 background-repeat:repeat-x;
Tile it down
12
54
WorldMags.net
13
15
17
Background positioning
Resize the background
16
Grab a background
14
18
55
WorldMags.net
Introducing CSS
Style a two-column layout
WorldMags.net
Main content
The sidebar
56
WorldMags.net
02
The wrapper
Header
Main content
03
04
05
Getting started
01
001 <body>
002
<div id=wrapper>
003
<div id=header>
004
<h1>header</h1>
005
</div><!-- END header -->
006
</div><!-- END wrapper -->
007
</div>
008 </body>
Sidebar section
The footer
06
07
001
<div id=footer>
002
<h3>footer</h3>
003
</div><!--END footer-->
004 </div><!-- END wrapper-->
005
Now the footer speaks for itself and will be our last HTML section we
will be adding. So again lets give it an ID name of footer and add it in
underneath the closing main_content div. Then again place in a header tag
using a <h3>. You will also notice we have added in an HTML comment to every
end div tag (</div>) to give us a clear indication of where each section ends. This
will help you if your HTML mark-up gets very busy.
57
WorldMags.net
Introducing CSS
Style a two-column layout
WorldMags.net
CSS reset
08
Wrapper styles
09
/* reset */
* {
padding: 0;
margin: 0;
001 #wrapper {
002
width: 960px;
003
margin: 0 auto;
004 }
The header
10
Now, for the header section we are going to float it left and give it a width
of 100%, which will guarantee our header spans the whole width of our
#wrapper. Then we push the header down 10px using margin. Here we have
used what is called shorthand CSS, which enables us to only pick the top margin.
Now give the background a colour and then 100px height.
001 #header {
002
float: left;
003
background: #f1f1f1;
004
margin: 10px 0 0 0;
005
width: 100%;
006
height: 100px;
007 }
12
11
Now to add some style. First thing is to float it left. Then give it an offwhite background colour and then by using margins we can give it some
breathing space. We then specify its width and height taking into consideration
the overall width of our wrapper so we have enough room for our sidebar.
001 #sidebar {
002
float: right;
003
margin: 10px 5px 5px 6px;
004
background: #ccc;
005
width: 324px;
006
height: 630px;
007 }
001 #main_content {
002
float: left;
003
background: #f0f0f0;
004
margin: 10px 5px 10px 0;
005
width: 620px;
006
height: 630px; }
58
WorldMags.net
The headers
13
14
001 #footer {
002
clear: both;
003
float: left;
004
background: #ddd;
005
width: 100%;
006
height: 100px;
007 }
15
001 #main_content {
002
float: right;
003
background: #f0f0f0;
004
margin: 10px 5px 10px 0;
005
width: 620px;
006
height: 630px;
007 }
16
As you can imagine, its very easy to make two larger content areas and not
have a sidebar at all even though it still can be called sidebar. So in your
CSS, if we think about how much space we have to play with, which is 960px, and
divide that into two. However, then we have to compensate for our margins, so
it may take you some messing about to get the right spacing without pushing
anything out.
Research alternatives
18
Be inspired
17
Now youve finished your basic two-column layout, take at look at some
of your favourite websites and see which layout they employ. As shown
above, www.webdesignermag.co.uk uses a two-column layout too.
59
WorldMags.net
Introducing CSS
Create a header
WorldMags.net
Create a header
Learn how to create a clean, simple and effective header for your website
Having clean and clear header for your website can be the difference between a successful and userfriendly experience and a cluttered and disorganised website that no one will want to visit again! You
dont want a first-time user coming to your site and not know how your navigation works, or your
company branding (logo) hidden under a load of over-useless graphics or text it doesnt even really
matter how effective the rest of your layout is.
Yes, this sort of thing has been known to happen (more often that web designers would like to
admit!) and this is why so many designers are turning to a relatively new role called user experience
or UX. So in this tutorial we will take a look at how we can create a simple, clean and useful header for
your site.
The logo
The background
60
WorldMags.net
Separators
Adding a separator to our
navigation links doesnt need to be
pure CSS as we did, but it is handy
using the border property
Create a header
Introducing CSS
WorldMags.net
01
Navigation list
03
02
In this step we are going to add in the navigation. What we will use here
is a standard unordered list and each list item (<li>) will have a link to each
page using the <a href= attribute. Then we will give our unordered list a class
name of navigation.
001 <body>
002
<div id=wrapper>
003
<div id=header>
004
<a href=index.html><div
id=logo></div></a>
005
</div><!-- END header -->
006 </body>
001 <body>
002
<div id=wrapper>
003
<div id=header>
004
<a href=index.html><div id=logo></div></a>
005
<ul class=navigation></li>
006
<li><a href=>home</a></li>
007
<li><a href=>about</a></li>
008
<li><a href=>blog</a></li>
009
<li><a href=>portfolio</a></li>
010
<li><a href=>services</a></li>
011
<li><a href=>contact</a></li>
012
</ul>
013
</div><!-- END header --> </div>
014 </body>
Main content
The CSS
04
05
001
<div id=main_content>
002
<h2>Hi, welcome to my
website</h2>
003
<p>It is a long established
fact that a reader will judge a
website by its layout.
004
</div><!-- END main content
-->
001
002
003
004
005
006
007
008
009
010
Now open up your styles.css file and at the top put in our simple reset.
The reset does exactly that resets every element to zero, which will clear
all the default styles that most browsers put on. Then, using the body tag we can
give our page a textured background using an image and leaving it to repeat
across the page. And then we set the font-family and size, here we have added
multiple fonts just incase our original chosen font isnt supported.
* {
padding: 0;
margin: 0;
}
body {
background: url(imgs/bg.jpg);
font-family: Verdana, Geneva, sans-serif;
font-size: 12px;
}
61
WorldMags.net
Create a header
Introducing CSS
WorldMags.net
The footer
07
The wrapper
06
Now we are going to centre our header and content using the wrapper
div. What we are doing here is making sure we have no margin at the
top or bottom and automatically find the difference on the left and right that
is in relation to our fixed width which we set to 960px. 960 pixels is mostly
used because it fits nicely within the lowest common denominator of screen
resolutions (1080 x 760).
001 #wrapper {
002
margin: 0 auto;
003
width: 960px;
004 }
The logo
08
09
001 #logo {
002
background: url(imgs/sc_logo.
png) no-repeat;
003
float: left;
004
width: 200px;
005
height: 200px;
006 }
001 .navigation {
002
float: right;
003
margin: 150px -50px 0 0;
004
width: 600px;
005 }
The navigation
Now lets style our navigation. We do this by floating the whole element
right then positioning it 150px down and then pulling it over to the
right using a negative margin of -50px. Never be worried about using negative
margins as they work very well. Then we give the navigation a width of 600px.
62
WorldMags.net
Introducing CSS
Create a header
WorldMags.net
Navigation anchors
11
Navigation buttons
001 .navigation li {
002
float: left;
003
list-style: none;
004 }
001 .navigation li a {
002
float: left;
003
color: #333;
004
padding: 6px 20px;
005
text-decoration: none;
006
border-right: 1px solid #333;
007
font-size: 16px; }
008
009 .navigation li a:hover {
010
background-color: #333;
011
color: #fff; }
The content
12
13
10
Now lets style our page content. While were here lets get sneaky and add
some CSS3 properties to make the background have rounded corners by
using border-radius: 6px. We then style the paragraphs give it some padding to
both the paragraph text and header tags.
001 #main_content {
002
float: left;
003
width: 900px;
004
height: 400px;
005
background: #fff;
006
border-radius: 6px;
007 }
008
#main_content p, h2 {
009
line-height: 22px;
010
margin-top: 10px;
011
padding: 20px;
012
}
14
The next step is to click the use grey button located at the very bottom
right and scroll down the page slightly. What we have first is the link tag
line that will link straight to the Google font servers and will always be available.
That way you can guarantee everyone will be able to see your chosen font. Copy
the link to your clipboard. Then paste it into your index.html file just underneath
our other CSS link within the <head> tag.
001
002
003
004
005
Google font-family
15
63
WorldMags.net
Introducing CSS
Create a sidebar
WorldMags.net
Create a sidebar
Learn how to create a clean navigation system for your website
A sidebar is without doubt the area that is most often created by web designers, because its the most
needed. It can hold all sorts of content: things such as extra navigation links, a search field and perhaps
some small thumbnail images that relate to your website it can be anything.
So in this tutorial were going to create a simple page layout that has a functional navigation and a
nice and simple sidebar that includes some content within. Were going to include within the sidebar
a list of links for that extra navigation we mentioned and a search bar above and also some thumbnail
images at the bottom to act as though we have a Flickr section very useful for any photographybased sites. So open up your favourite text editor and lets get started.
The width
A thin-looking sidebar
wouldnt help anyone
unless you have no intention
of anything but small
thumbnail images!
Navigation
Having a list of links for an
extra navigation will allow you
to add in links that you may
not have had the room to fit in
the main navigation menu
The thumbnails
We added this feature
because you see it all the time.
People who have a blog can
use a plugin that allows them
to feature their Flickr photo
64
WorldMags.net
Create a sidebar
Introducing CSS
WorldMags.net
Getting started
01
02
Lets now add in our sidebar section. All we do here is create a div ID with
the name of sidebar just underneath the closing header div </div>. Then,
using the code above, within our sidebar section lets add in a search field that will
just sit there and look pretty. After the <!-- END header --> tag add:
Sidebar navigation
03
Sidebar images
04
Well now add some images to sit below our navigation list. We have
the same image here for both, set to the size of 100x100px. Weve given
them a class name of thumb so we can use CSS to position them better without
relying on the img tag. Also weve given this section a title with the <h3> tag.
After your navigation list add:
001 <h3>My flickr images</h3>
002 <img src=imgs/thumbnail.jpg height=100 width=100 class=thumb>
003 <img src=imgs/thumbnail.jpg height=100 width=100 class=thumb>
The CSS
The wrapper
05
06
001
002
003
004
005
006
007
008
009
010
001 #wrapper {
002
margin: 0 auto;
003
width: 960px;
004 }
Open up your styles.css file and at the top add in the universal selector
that will allow you to reset every element(<p>, <h1>, div, etc) to zero
margin and padding. Then using the body tag we can set the background
colour to an off white #f1f1f1 and set our default font style and size.
* {
padding: 0;
margin: 0;
}
body {
background: #f1f1f1;
font-family: Verdana, Geneva, sans-serif;
font-size: 12px;
}
65
WorldMags.net
Introducing CSS
Create a sidebar
WorldMags.net
Stick to the right
07
Were styling our header by giving it a 100% width with a height of 250px.
Adding the logo is also going to be very simple as well only be using text
for now. Weve given ours a drop shadow using the text-shadow property.
001
002
003
004
005
006
007
008
009
010
011
012
#header {
float: left;
width: 100%;
height: 250px;
}
#logo h1{
font-size: 35px;
float: left;
margin-top: 130px;
color: #dac91a;
text-shadow: 1px 1px 3px #333;
}
The navigation
08
Now lets style our navigation. We can do this by floating the whole element
right, positioning it 150px down and then pulling it over to the right using a
negative margin of -50px. Then we give the navigation a width of 600px. To bump
everything to a horizontal position we float all the <li> left, then create our button
separator by adding a border-right to the navigation li a selector.
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
.navigation {
float: right;
margin: 150px -50px 0 0;
width: 600px;
}
.navigation li {
float: left;
list-style: none;
}
.navigation li a {
float: left;
color: #333;
padding: 6px 20px;
text-decoration: none;
border-right: 1px solid #333;
font-size: 16px;
}
09
WorldMags.net
Create a sidebar
Introducing CSS
WorldMags.net
The sidebar
11
Google fonts
10
001
002
003
004
005
006
007
008
009
010
011
012
013
014
13
In this step lets style our search field. First of all we push it down slightly
and then make sure anything underneath it is 50px away. Then we slightly
push it away from the left edge using 20px. And lastly we give the input field
some padding to make it a bit more attractive.
001 #search_form {
002
003
margin: 10px 0 50px 20px;
004 }
005
006
#search_form input{
007
008
padding: 5px;
009 }
001 #sidebar {
002
float: right;
003
width: 300px;
004
height: 100%;
005
background: #fff; }
006 #sidebar h3 {
007
padding-left: 20px;
008
color: #333; }
Sidebar list
12
001
002
004
005
006
007
008
009
010
011
012
013
014
.sidebar_list {
margin: 20px; }
.sidebar_list li {
list-style: none;
margin: 10px;
padding-bottom: 10px;
border-bottom: 1px dotted #ddd;
}
.sidebar_list li a{
text-decoration: none;
color: #333;
font-size: 13px;
}
Finishing off
14
67
WorldMags.net
Introducing CSS
Add content to your website
WorldMags.net
The width
68
WorldMags.net
02
Now in this step we are going to give our main content area a title that will
welcome everyone to the website. We do this very easily by adding in a
<h2> tag and a nice message within. What we will do is use CSS later to see what
we can do to make this look a little nicer.
001 <h2>Hi, Welcome to my website</h2>
Getting started
01
Welcome text
03
Adding an image
04
Now we can add in an image within our welcome text. The idea here is to
have a small thumbnail image of something that relates to the website. So
place your image tag <img src= above the welcome text just sitting underneath
the header. Then we will use CSS later to float it to the right.
Content image
06
Lets open up our styles.css file. We can point to the #main_content div
and then hock onto the p tag. We can then use multiple selectors here
and use the same style properties and values for the<h2> tag.
001 #main_content p, h2 {
002
line-height: 22px;
003
margin-top: 10px;
004
padding: 20px;
005
width: 350px;
006
}
001 .main_thumb {
002
float: right;
003
margin: 40px;
004
border: 1px solid #fff;
005
box-shadow: 0px 4px 6px #999;
006 }
05
69
WorldMags.net
Introducing CSS
Add content to your website
WorldMags.net
The main content height
08
Video
07
Next we want to add the video to our main content area. Now we can get
really technical and use an HTML5 or flash player here, but to keep things
really simple, we can shoot over to youtube.com and copy and paste the embed
code within our index.html page. Then we want to be able to shift this video about
using CSS, so it would make sense to wrap a div around it with an ID of video.
001
002
003
004
<div id="video">
<iframe width="420" height="315" src="http://www.youtube.com/embed/
kNn44gHqanM" frameborder="0" allowfullscreen></iframe>
</div>
09
All we are going to do here is position the video using CSS. Now it makes
sense to float the video left. Then we are going to use margin to push it
away from the edges and anything that may be surrounding the video will now
have a generous amount of white space. Then lets add a black 5px border to
finish off our video.
001 #video {
002
float: left;
003
margin: 20px;
004
border: 5px solid #000;
005 }
001 #main_content{
002
float: left;
003
height: 100%;
004
width: 630px;
005
background: #fff;
006
border-radius: 6px;
007
margin-bottom: 40px;
008 }
Horizontal rule
10
11
hr {
color: #ddd;
width: 570px;
margin-left: 20px;
}
12
So now you should get the idea of how and what we can add for our main
content. To get a real feel of it, lets add something underneath our video.
What we can do then is add in another thumbnail image. So the best way would
be to use the same image but give it a different class name of main_thumb2 and
place this directly under our closing div of our video.
WorldMags.net
13
14
So the next step would be to add in some more text that could be used for
a summary/excerpt of our video. Underneath our new thumbnail image,
place some more dummy text that is wrapped within paragraph tags <p> with a
class name of vid_excerpt so we can style it using CSS.
001
002
003
004
005
006
007
Bottom content
16
The excerpt
15
Now all we need to do is float our video excerpt to the right and give it
some margins with 50px to the right, and 40px to the bottom.
001 .vid_excerpt {
002
float: right;
003
margin: 0 50px 40px 0;
004
}
17
001
002
003
004
005
006
hr {
color: #ddd;
width: 570px;
margin-left: 20px;
float: left;
}
Going further
18
As we said in the intro text to this tutorial, its down to you as to what
your content should include. Later in this book we explore adding maps,
newsletters, image sliders and more!
71
WorldMags.net
Introducing CSS
Add content to your footer
WorldMags.net
Getting started
01
About us
02
Footer links
03
Newsletter sign up
04
72
WorldMags.net
05
001 #footer {
002 clear: both;
003 height: 200px;
004 width: 100%;
005 background: #fff;
006 margin-bottom: 20px;
007 }
The links
06
08
001 .footer_links li a {
002 text-decoration: none;
List items
07
003
004
005
006
007
color: #333;
}
.footer_links li a:hover {
color: #000;
}
About text
09
WorldMags.net
Responsive design
Introduction to
Responsive Web Design
Ultimate guide to discovering responsive web design and
how to start using it today
Responsive web design
With the growing plethora
of internet enabled devices
it is important to ensure
your website is responsive.
Understanding responsive
web design practices will help
you build websites suitable for
every screen size whether large,
medium or small.
<above> More websites, including the popular Mashable news website, are becoming responsive
WorldMags.net
Fluid Layouts
Quick Tip
In the past we had liquid layouts, where only the layout columns
structural elements and text were truly fluid which expands and
contracts as the browser window size changes. But this was not
truly flexible, images were not fluid which could easily break
layouts. This included structural layouts which directly broke the
layout if pushed enough.
This is where fluid grids excels where traditional liquid layouts
failed. Fluid grids are a fundamental key principle of responsive
web design. Rather than designing for rigid pixels or arbitrary
percentage values, we can use grids to provide structure and use
relative units to provide fluidity defined by using maximum width
to carefully design in proportions.
When designing in traditional pixel based unit, there is a formula
we can use to identify the percentage values, by using:
Common responsive
breakpoints you may want to
use http://responsivedesign.
is/develop/browser-featuresupport/media-queries-forcommon-device-breakpoints.
<div class="wrapper">
<section><!-- content --></section>
<aside><!-- content --></aside>
</div>
75
WorldMags.net
Responsive design
The CSS:
001
002
003
004
005
To convert the fixed units and turn them relative we can use the
flexible grid formula:
001
002
003
*/}
004
section,
aside {margin: 2.083333333%; /* 20 / 960 = 0.02083333333 */ }
section {float: left; width: 66.666666666667%; /* 640 / 960 = 0.66666666666667
aside {float: right; width: 31.25%; /* 300 / 960 = 0.3125 */ }
We set our context as our wrapper which is 960 and the target value is
either our section, aside and margin. Using this formula we can apply
this throughout our grid to build a dynamic website to scale every
viewport size.
Quick Tip
When designing any website, planning and setting out user goals is
essential to crafting the best possible experience; users need to be
able to interact with your website with minimal thinking.
Its beneficial to organise the site structure and mapping out the
architecture and possible framework that dictates the different
break points the site will respond to. Its good to wireframe and map
out your website using traditional tools simply with paper and pen.
Or use helpful digital software such as the online wireframing tool
Balsmiq (balsamiq.com).
After mocking up your website, its not necessary to design pixel
perfect desktop designs. Because it will only be part of one static
snapshot of a layout which is in constant fluid motion. Nor does it
make sense to design every single screen imaginable.
When designing a responsive website it is important to use a
grid system. Typically grids
are measured in pixels but
Setup grids and breakpoints
now each grid will become a
percentage of a page width.
1 Calculate grids and
2 Download
Be aware when the browser
breakpoints
Click download your Gridpack
Head over to http://gridpak.com/
to download the PNG for design
window size changes the
to setup the number of columns
purposes and CSS. Give credit for
column width will too, this will
and breakpoints.
your resources on your site.
vary between resolutions.
Use Responsify to generate your
responsive template including
grids columns, gutter width
and breakpoints http://app.
responsify.it/
76
WorldMags.net
1 Setting up mobile
breakpoints This will be set for
screen width of 320px and max
width of 480px.
Modular design
To make your designs more fluid and ensuring it adapts to whatever
environment it is viewed on even on a narrow screens such as
mobile devices you will need to think of each element of your
webpage to be modular.
This includes breaking down the page into components for
example the header, navigation, main content, sidebar and footer.
Imagine this as a puzzle that can be reassembled or re-organised to
fit on smaller screen size.
Its important to keep the information architecture coherent for
example the links need to be grouped together in a navigation and
that content should still be linear and easy to navigate.
Navigation
Search
Responsive Images
Flexible grids
3 Setting up desktop
breakpoints This will be set
for a minimum screen size of
1224px .
77
WorldMags.net
Responsive design
Media Queries
We can set the media type to either all, screen, print, tv and
even braille. Each media query includes a media type followed by
one or more expression. Logical operators in media queries help
build powerful expressions. We can use the and operator to add
extra conditions:
section, aside {
float: none;
width: auto;
}
001 @media all and (min-width: 600px) and (max-width: 940px) {...}
The above selects all media types between 600px and up to 940px.
Besides setting the min- and max-width we can also use the
orientation media feature to determine if a device in landscape or
portrait mode.
2 Link to JavaScript
Link to respond.js in your
<head> right after where you
have put your style sheets.
78
WorldMags.net
User agents using HTML4 algorithm will now simply ignore media
queries that you have inputted.
1 Serve high-res images to
retina displays Download
Retina.js at http://imulus.github.
io/retinajs/.
Viewport
If you built a responsive website and try to view it on a mobile
device you will notice the website has scaled to the desktop size.
By adding a viewport meta tag we can ensure browsers scale the
webpage to fit the screen size its on, with:
001 <meta name=viewport content=width=device-width, initial-scale=1>
Fluid images
max-width: 100%;
Clearfix
Media query
Quick Tip
Zoom: 1 fix
Calculated grids
WorldMags.net
Responsive design
Applying this fix will allow images to scale down dependent on the
containers width.
Compressing CSS
Mobile first
1 Compress CSS
To reduce file sizes and the
amount of HTTP requests head
over to http://www.shrinker.ch/
2 Upload files
Upload all your CSS files and
click shrink
3 Copy shrinked file
Copy the shrinked code you have
created into a new CSS file called
compressed.css
Browser testing
Quick Tip
Download GuideGuide
Photoshop plugin (http://
guideguide.me/) to set
up your own guides in
Photoshop, with many
variants and ease.
1 Head to Download
Go to foundation.zurb.com/
develop/download.html You may
customise the components and
grid system
80
WorldMags.net
Futher reading
There are a lot more reading
to further your discovery on
responsive web design and
to continue on improving
your skills.
Websites that contain
great resources on responsive
web design include This is
Responsive http://bradfrost.
github.io/this-is-responsive/
a collection of news and
resources. A beginners guide
to responsive web design
resource list www.targetlocal.
co.uk/responsive-webdesign-resources/.
Books that help further
your skills include HTML5 for
Web Designers http://www.
abookapart.com/products/
html5-for-web-designers
and CSS3 for Web Designers
www.abookapart.com/
products/css3-for-webdesigners and Responsive
Web Design www.
abookapart.com/products/
responsive-web-design all
are by A Book Apart.
Checkout some great
examples of the best
responsive websites out
there on Awwwards www.
awwwards.com/websites/
responsive-design/ and
more to see over on Get
with the Future socialdriver.
com/2014/03/05/65-bestresponsive-website-designexamples-2014/.
WorldMags.net
Bootstrap
WorldMags.net
Responsive design
Bootstrap
Responsive design made easy
Bootstrap is a powerful yet approachable front-end framework designed to
make it quicker and easier to develop user-friendly websites
It was in August 2011 that Mark Otto, a developer
at Twitter, announced a new framework that the
social media platform had developed internally,
with the aim of providing a consistent API while
developing the popular micro-blogging tool.
Bootstrap was designed to help Twitters
developers avoid the mish-mash of competing
and incompatible frameworks and libraries.
It provides a unified toolset for all front-end
development requirements including advanced
typographical control, a built-in grid system,
and the option to use components to extend
functionality to suit any particular needs that go
beyond the basic framework common to every
website. Twitter have since produced one of their
most compatible and functional websites to
date, with the sleek new design not only being
pleasing on the eye, but providing its users with a
basis of comparison to the other social networks.
Fundamentally Bootstrap is pure CSS, but
as its built with LESS (a pre-processor that
offers flexibility beyond what normal CSS can
achieve) and has Sass support, there is a range of
additional benefits over and above plain styles.
The core CSS is broken into components,
allowing it to be easily managed and adapted.
Each file in the set of Less source files deals
with one particular characteristic, so you have a
82
WorldMags.net
Bootstrap
Responsive design
WorldMags.net
Get started
Bootstrap works by providing a clean, uniform approach
to creating the most common user interfaces on the web.
Whether youre creating a simple brochure website, or a
complex form, the same core components make up the
site design in terms of styles and content structure. By using
Bootstrap you can save time, pulling in ready-made controls,
layout elements and styles. This leaves more time to work
on aesthetics and testing.
The first thing youll need to get started with Bootstrap
is the framework itself. Visit getbootstrap.com to download
the latest version of Bootstrap. All the media queries, grid
sizing are all ready and setup included in this download.
Once youve downloaded the framework, you simply
need to plug in the CSS and JavaScript files to create your
first Bootstrap page.
The grid
WorldMags.net
Bootstrap
WorldMags.net
Responsive design
Benefits
Modular
The Bootstrap framework is modular, so you only need
to call in the elements you need for your specific project,
making it relatively lightweight to deploy.
Responsive
The grid system is fully responsive, allowing you to
design once and deploy your website across multiple
device profiles, all without having to do any complex
mathematics or calculations.
Quick to develop
Bootstrap is built on standard CSS and JavaScript making
it very quick to develop the accompanying HTML, and
Custom
download
Get a custom download of Bootstrap
by visiting getbootstrap.com and
clicking on Customise. You can then
specify which components, variables,
plug-ins and base-styles are included.
The download includes minimised
files for low-bandwidth deployment to
production sites, and uncompressed
versions for testing.
84
WorldMags.net
Bootstrap
Responsive design
WorldMags.net
We give you a quick rundown of our six favourite templates and some of the
features they offer designers
1. mPurpose
4. JA Appolio
2. Fullby
5. DashGum
3. StanleyWP
6. Awesome Photography
WorldMags.net
Bootstrap
WorldMags.net
Responsive design
Customisation
Components are little more than
HTML markup classified using a
combination of structure and classes.
As a result, theyre incredibly flexible
and infinitely customisable. If you
want to change the look or the way to
interact, you simply need to edit the
associated CSS and/or JavaScript.
86
WorldMags.net
Bootstrap
Responsive design
WorldMags.net
5 Popular UI
Components
1. Jumbotron
This component encapsulates a popular layout
technique: an oversized typographical box. Typically
such an area includes a call to action, so the Bootstrap
Jumbotron has a button built in to the design which
is, of course, easily customised.
4. Input groups
Input groups make it easy to develop clean, validated
user forms that respond consistently. The core styling
is simple and follows the current trend for minimalist
aesthetics, you can also append or prepend text or
buttons either side of text based inputs.
5. Badges
87
WorldMags.net
Bootstrap
WorldMags.net
Responsive design
Basic HTML
Download the framework
01
02
03
04
88
WorldMags.net
Bootstrap
Responsive design
WorldMags.net
A little bit
LESS.js
Add a Jumbotron
05
Make it responsive
06
WorldMags.net
Bootstrap
WorldMags.net
Responsive design
Grab a template
01
02
03
04
90
WorldMags.net
Bootstrap
Responsive design
WorldMags.net
Responsive carousel
The carousel slideshow component comes fully responsive be sure that your images are wide enough to
encompass all common screen widths. This can create a big impact, especially on portfolio websites where
images are used to show off your work.
05
06
07
08
WorldMags.net
Bootstrap
WorldMags.net
Responsive design
Resources
Bootstrap has a lot of resources
available on the web, check out five
of our favourites below
Bootstrap
getbootstrap.com
Straight from the source, the Bootstrap website
provides an off-the-shelf download of the framework,
a customisable download builder, and a full set of
documentation for the framework covering all the
standard plug-ins, components as well as the grid system.
This is also the place to get the latest official news
Bootstrap Google+
https://plus.google.com/communities/
110370020620457615447
This is the Google+ community group for Bootstrap, visit
here if youd like to seek help from other users, or to learn
about the latest news. This group currently boast over
4000 active members. There are regular updates when
new templates, components and plugins are launched.
Bootsnipp
bootsnipp.com
A handy resource site that gathers together HTML
snippets, themes, components and plug-ins in a gallery
thats easy to browse. Users can contribute snippets,
sharing their own work with the community for mutual
benefit, and the site also features a handy page of links to
other Bootstrap resources for quick reference
Be inspired
Bootstrap is the underlying
framework for some amazing
websites take a look at two of the
best to get some inspiration for your
next project
Lexi Miller
http://leximiller.com/
This clean, simplistic and gorgeous looking feminine
website sells fashionable athletic clothing. It takes
advantage of the responsive native in the Bootstrap
framework and utilises it as its own.
Start Bootstrap
http://startbootstrap.com/bootstrap-resources/
Kickstrap calls itself a complete kit for making websites,
building on top of Bootstrap with additional support for
libraries such as Raphael without the pain of manually
bringing together disparate resources. A useful resource
for sites that need to go further than basic Bootstrap
Bootswatch
bootswatch.com
Bootswatch is a simple theme site for Bootstrap, but rather
than focus on the complete end product, it provides a
core set of styles that integrate beautifully with the basic
Bootstrap components to create markedly different
aesthetic treatments. Its limited in the range of themes it
offers, but many are worthy of forming the basis for your
own customisations.
Entora
http://entora.com/
A beautiful entertainment source to follow your favour
artists. This website takes advantage of the mobile first
fluid grid system using the extra small grid option to
force grids to be horizontal at all times.
92
WorldMags.net
Bootstrap
Responsive design
WorldMags.net
Bootstrap 3
Since the release of version 3, lets look back comparing to the predecessor
and on advancement it has made.
The difference between Bootstrap 2 and Bootstrap 3 is
that version 3 takes a mobile-first approach to ensure
your designs is fully responsive on the get go.
Under the hood the developers have focused on
trimming and rationalising the framework so that, for
example, rather than internally referring to an alert box
93
WorldMags.net
Responsive design
Build a custom
Foundation template
Get started using Zurbs Foundation framework to build a responsive template
that can be reused for any project
When starting a new responsive web design project, trying to custom develop your own framework
that includes a flexible grid system, media queries, typography, JavaScript media including video,
carousels, lightboxes and more can be exhausting. Not to mention the changing web arena, youll have
to rigorously maintain and update your framework to keep up to date with all the new features.
Using an open source framework like Foundation by Zurb helps to relieve the stress on developers.
This robust and flexible framework is well documented and has a host of ready components to reuse;
the best part is you can easily customise it, adding and removing functionality to suit your needs.
Foundation is built to be mobile first, so as soon as you start using this framework for your web project
its instantly responsive.
Through this tutorial well touch upon some of Foundations core components and how to assemble
these to create your own custom template, which can be reused for any project.
94
WorldMags.net
color: #666;
}
h1, h2, h3, h4, h5, h6 {
font-family: Cabin, sansserif;
font-weight: 500;
color: #666;
}
01
downloaded at www.google.com/
fonts#UsePlace:use/Collection:Cabin.
Its good practice not to directly edit
the foundation.css, which contains
all the framework styles. We should
house all our custom styles in a
separate CSS file called style.css.
001
002
003
05
<link href=http://fonts.
googleapis.com/
css?family=Cabin:400,500
rel=
stylesheet type=text/css>
<link rel=stylesheet
href=css/foundation.css />
<link rel=stylesheet
href=css/style.css />
Basic styles
04
Unarchive the zip
02
HTML head
03
001
<above>
The Top Bar plug-in is fully responsive
navigation, even the drop-down menus are
device friendly
body {
WorldMags.net
Responsive design
<left>
Using the Top Bar plug-in you
can easily create functional
drop-down menus, the only real
work is styling it up
<below>
Incorporating a responsive
rotating slider with swipe- and
touch-enabled functionality is a
breeze using the Orbit plug-in
002
003
004
005
006
007
008
Sub menu
06
001
002
003
004
005
006
<section class=top-bar-section>
<ul class=left>
<li class=hasdropdown>
<a class=active
href=#>
Main Item 1</a>
<ul class=dropdown>
<li><a
href=#>Dropdown
Option</a></li>
</ul>
</li>
</ul>
</section>
007
008
009
010
07
.top-bar {
-webkit-box-shadow: 0px 3px
7px 0px rgba
(50, 50, 50, 0.75);
96
WorldMags.net
-moz-box-shadow:
0px 3px
7px 0px rgba
(50, 50, 50, 0.75);
box-shadow:
0px 3px
7px 0px rgba
(50, 50, 50, 0.75);
004
005
006
007
008
009
010
011
012
<div class=row>
<div class=large-12 columns>
<ul class=orbit-container
data-orbit>
<li>
<img src=img/
slides/slide-1.jpg
alt=slider 1 />
<div class=orbitcaption>
Text to go here
</div>
</li>
</ul>
</div>
</div>
Orbit JavaScript
09
}
});
</script>
002
<div class=large-6
columns>
<div class=flexvideo>
<iframe
width=560 height=315
src=//www.youtube.com/embed/_
ejeqxRdGwkframeborder=0
allowfullscreen></iframe>
</div>
</div>
003
004
Basic content
08
004
005
time_speed: 1000,
pause_on_hover:true,
bullets: false,
001
002
003
006
007
008
009
010
011
<script>
$(document).foundation({
orbit: {
animation: fade,
animation_speed:500,
10
11
<div class=row>
005
006
Panel component
12
Lightbox gallery
13
WorldMags.net
Responsive design
<above>
The Orbit plug-in cannot handle variable height images but the Clearing Lightbox plug-in can
and makes scrolling through images friendly
010
011
012
013
014
014
001
002
003
004
005
006
007
008
{
009
010
14
margin-left: 10px;
}
Common styles
15
Gallery styles
.gallery {
padding: 20px 0;
background-color: #f2f2f2;
}
.clearing-thumbs li {
margin: 0 20px 20px 0;
}
.clearing-thumbs li:first-child
002
003
004
.main-content, .gallery,
.contact-us {
margin-bottom: 30px;
text-align: center;
}
005
006
007
16
</div>
</form>
Error message
17
Email input
18
001
002
003
Contact form
Creating user-friendly and
HTML5 validation-ready forms
is wonderfully simple in Foundation.
<form data-abide>
<div class=name-field>
<label>Name:
<input type=text
placeholder=
James Smith
required pattern=
[a-zA-Z]+ />
</label>
004
005
006
<div class=email-field>
<label>Email:
<input type=email
placeholder=
james@email.com required
/>
</label>
<small class=error>
Please enter your email</small>
</div>
98
WorldMags.net
19
001
002
003
004
005
006
007
<div class=message-field>
<label>Message:
<textarea
placeholder=Enter your
comments here required></
textarea>
</label>
<small class=error>Please
enter your comments</small>
</div>
<button type=submit>Submit</
button>
Form styles
20
label {
text-align: left;
color: #666;
}
textarea {
height: 200px;
}
</div>
<div class=large-6
columns>
<ul class=inlinelist right>
<li>
<a
href=#>Link
4</a>
</li>
</ul>
</div>
</div>
</footer>
008
009
010
011
012
013
014
015
22
005
006
Foundations wide
range of navigation
options
001
002
003
004
007
<footer class=row>
<div class=large-12
columns>
<hr />
<div class=large-6
columns>
<p>©Copyright
notice to go here</
p>
006
007
21
gradient(180deg, rgb
(43, 43, 43) 30%, rgb(29, 29,
29) 70%);
footer {
color: #fff;
background: rgb(43, 43, 43);
background: -moz-lineargradient(90deg,
rgb(43, 43, 43) 30%, rgb(29, 29,
29) 70%);
background: -webkit-lineargradient
(90deg, rgb(43, 43, 43) 30%,
rgb
(29, 29, 29) 70%);
background: linear99
WorldMags.net
Responsive design
Build a responsive
WordPress theme
As the most advanced responsive framework available, Zurbs Foundation is
ideal for your latest WordPress project
Previously to incorporate Zurbs Foundation framework into WordPress you had to manually link the
necessary JavaScript and CSS using the WordPress functions wp_enqueue_script and wp_enqueue_
style. But now, thanks to Zurb and the popularity of WordPress, Zurb has provided a starter-theme
called FoundationPress, which you can download directly from its GitHub page to start building your
own WordPress theme with the Foundation framework.
The purpose of this ultimate starter theme is to act as a springboard; it comes packed with useful
re-useable components, a 12-column responsive grid, JavaScript functions and much more. This starter
theme contains all the necessary design elements, including the JavaScript and CSS libraries.
Still, FoundationPress is not an all-in-one WordPress theme with plugins, shortcodes, custom
options or custom templates it is only to be used as a starting point. Luckily it has done most of the
hard work for us including setting up widgets, navigations, displaying blog posts and general clean-up
of WordPress.
100
WorldMags.net
Download
FoundationPress
01
Custom stylesheet
02
<link rel=stylesheet
03
04
005
006
007
<header class=main-head>
<div class=row>
<div class=large-12
columns>
<h1 class=title><?php
bloginfo
( name ); ?></h1>
</div>
</div>
</header>
05
101
WorldMags.net
.main-head {
margin-bottom: 2em;
Responsive design
<top>
In WordPress, activate FoundationPress starter
theme. This theme includes all the Foundation
framework library
003
padding: 1.2em;
004
background: #00b3d3;
005
background: -moz-radialgradient(center,ellipse cover,#00b3d3
0%, #007295 100%);
006
background: -webkitgradient(radial, center
center, 0px, center center,
100%, color-stop(0%,#00b3d3),
color-stop (100%,#007295));
007
background: -webkit-radialgradient (center, ellipse
cover, #00b3d3 0%,#007295 100%);
008 }
009 .main-head h1 {
010
text-align: center;
011
font-weight: 900;
012
text-transform: uppercase;
013 letter-spacing: 10px;
014
text-shadow: 1px 1px 2px rgba
(50, 50, 50, 0.59);
015
font-size: 2.5rem;
016
color: #fff;}
<bottom>
FoundationPress allows you to order menus to be
on the left or right side of the menu and enable
for mobiles
Add a search
06
001
003
004
Customise search
07
005
006
<div class=row>
<?php do_action
(foundationPress_
searchform_top); ?>
<div class=large-8 columns
searchbox>
<input type=text value=
name=sid=splaceholder
=<?php esc_attr_e(Search,
FoundationPress);?>>
</div>
<?php do_
action(foundationPress_
searchform_before_search_
button); ?>
102
WorldMags.net
008
009
has_post_
thumbnail() ) {the_
post_thumbnail
(large); } ?></a></
figure>
<?php the_excerpt(); ?>
<p>Posted on <?php
the_time(F jS, Y
); ?> in <?php the_
category(, );
?></p>
<p class=byline
author>Written by
<?php the_author_posts_
link(); ?>
</p>
<a href=<?php the_
permalink(); ?>
class=button>Read
more</a>
</div>
008
009
Modify index.php
010
08
Blog post
09
003
004
005
006
007
011
012
008
009
11
.searchbox, .searchbutton {
padding: 0 15px;
}
10
12
001
002
003
004
<div class=bottom-sidebar>
<aside id=sidebar
class=row data-equalizer>
<?php do_action
(foundationPress_
before_sidebar); ?>
<?php dynamic_
sidebar(sidebar-widgets);
WorldMags.net
Responsive design
<top left>
Easily set up and use shortcodes in your
site to take advantage of Foundations
library of components
<bottom left>
Using WordPress shortcodes, we were
able to add Foundations alert box
components throughout the site
005
006
007
?>
<?php
do_action(foundationPress_
after_sidebar); ?>
</aside>
</div>
Widgets
13
14
001
001
002
003
004
005
Shortcode array
.bottom-sidebar {
padding-top: 10px;
background-color: #cecece;
}
Set up shortcodes
15
002
003
004
005
006
007
008
function foundation_add_alerts
( $atts, $content = null ) {
extract( shortcode_atts(
array(
type => ,
shape => ,
close => true,
class =>
), $atts ) );
16
$class_array[] = ( $shape ) ?
$shape : ;
$class_array[] = ( $type ) ?
$type : ;
$class_array[] = ( $class ) ?
$class : ;
104
WorldMags.net
$class_array = array_filter(
$class_array );
$classes = implode( , $class_
array );
Shortcode markup
17
001
002
003
004
005
006
007
18
001
002
003
004
function register_shortcodes() {
add_shortcode(alert,
foundation_add_alerts);
}
add_action(init,
register_
shortcodes);
Shortcodes to use
19
001
002
003
[alert type=success
shape=radius
close=true]This is a success
message[/alert]
[alert type=secondary)
shape=radius
close=true]This is a standard
message[/alert]
[alert type=alert shape=round
close=false]This is an alert
message[/alert]
Alert boxes
20
Footer
004
005
006
007
008
009
010
<?php wp_list_pages();
?>
</ul>
<?php do_
action(foundationPress_
before_footer); ?>
<?php dynamic_
sidebar(footerwidgets); ?>
<?php do_
action(foundationPress_
after_footer); ?>
</div>
</footer>
22
001
002
003
004
005
006
007
008
009
010
011
012
013
.main-footer {
padding: 10px 0;
background-color: #9c9c9c;
}
.pagenav ul {
margin: 10px 0 0 0;
}
.main-footer li {
float:left;
margin-right: 10px;
list-style: none;
}
21
<footer class=main-footer>
<div class=row
<ul>
105
WorldMags.net
Responsive design
Make a responsive
menu for a retina screen
Make sure your menu is both responsive and ready for
retina screens by using custom fonts instead of images
Designing the navigation element for your website in this age of mobile devices and differing screen
widths can be a real pain in the mouse. Balancing usability with aesthetic credibility is the challenge that
responsive design now presents to all designers. There are a wide variety of solutions and techniques
available to solve the issue, from fixed drop-down menus to side-sliding variations. The problem is that,
while these solutions all solve the problem of maintaining functionality at different screen widths, they
can sometimes lacking visual impact.
These days its nice to see a menu that remembers to look good, too. Longer, scrolling pages are
reducing the number of menu elements some sites need to present, and those sites, in particular, can
afford to be a little more adventurous with how they deliver the navigation. So its time to give the
responsive menu a much needed paint job and raise it above the purely functional. This tutorial will
demonstrate how to create a responsive menu that is both eminently usable and visually striking. And
to keep it retina friendly, well be using a custom-made icon font rather than images.
As more and more screen sizes flood into the market, it pays to keep your responsive elements as simple as possible to avoid meeting a width they cant
deal with. Having three breakpoints, roughly representing PC, tablet and smartphone, is a tried and trusted approach to this problem
106
WorldMags.net
01
Create
a custom font
02
03
uniF4F1,.icon-skull,.icon-uniF539,.
icon-rocket,.icon-menu {
012
font-family: 'icomoon';
013
speak: none;
014
font-style: normal;
015
font-weight: normal;
016
font-variant: normal;
017
text-transform: none;
018
line-height: 1;
019
-webkit-font-smoothing:
antialiased;
020 }
021
.icon-happy:before {content:
"\e603";}022 .icon-loved:before
{content: "\e61c";}
023 .icon-uniF4F1:before {content:
"\e613";}
024 .icon-skull:before {content: "\
e607";}
025 .icon-uniF539:before {content:
"\e612";}026 .icon-rocket:before
{content: "\e600";}
027
Base CSS
04
001
002
003
004
005
006
007
008
009
.main,
.container > header {
width: 100%;
margin: 0 auto;
padding: 16px 32px;
}
.main {
max-width: 1300px;
min-height: 640px;
010 }
011 header {
012
text-align: center;
013
font-size: 16px;
014
background:
rgba(255,255,255,0.6); 015 }
015 header h1 {
016
font-family: 'Hammersmith
One', sans- serif;
017
font-size: 75px;
018
line-height: 0.8;
019
margin: 0;
020
font-weight: 300;
021
color:#3f3782;
022
}
023 .movie {
024
font-size:102px;
025
color:#e63c2b;
026 }
Menu HTML
05
WorldMags.net
Responsive design
As more and more screen sizes flood into the market, it pays to keep your responsive elements as simple as possible to avoid meeting a width they cant
deal with. Having three breakpoints, roughly representing PC, tablet and smartphone, is a tried and trusted approach to this problem
07
08
06
09
108
WorldMags.net
10
001 body {
002
font-family: 'Hammersmith
One', sans- serif;
003 background: url(../img/bg.jpg);
004 }
005 margin: 20px;
006
border: 1px solid red; /*
take off asap */
007 }
008
11
Tablet animation
12
Rather than having to adapt the layout per screen width, well use each breakpoint as an opportunity for redesigning
109
WorldMags.net
Responsive design
Last transition
13
16
17
14
Background changes
15
Having fewer menu elements means that we can avoid having to hide them. Instead we can
arrange them within our screen space
110
WorldMags.net
001
<!DOCTYPE html>
002
<html lang="en">
003
<head>
004
<meta charset="UTF-8" />
005
<meta http-equiv="X-UA-Compatible"
content="IE=edge,chrome=1">
006
<meta name="viewport" content="width=device-width,
initialscale=1.0, user-scalable=no">
007
<title>London Movie Reviews</title>
008
<link rel="stylesheet" type="text/css" href="css/style.
/>
009
<link href='http://fonts.googleapis.com/
css?family=Hammersmith+One' rel='stylesheet' type='text/css'>
010
</head>
011
<body>
012
<div class="container">
013
<header>
014
<h1>LONDON<br><span class="movie">MOVIE</
span><br>REVIEWS</
015
h1>
016
</header>
017
<div class="main">
018
<nav class="nav">
019
<ul>
020
<li><a href="#"><span class="fon icon-happy"></span><span
class="item">COMEDY</span></a></li>
021
<li><a href="#"><span class="fon icon-loved"></
span><span class="item">ROMANCE</span></a></li>
022
<li><a href="#"><span class="fon icon-uniF4F1"></span><span
class="item">ACTION</span></a></li>
023
<li><a href="#"><span class="fon icon-skull"></span><span
class="item">HORROR</span></a></li>
024
<li><a href="#"><span class="fon icon-uniF539"></span><span
class="item">DRAMA</span></a></li>
025
<li><a href="#"><span class="fon icon-rocket"></span><span
class="item">SCI-FI</span></a></li>
026
$(window).scroll(function(){
027
</ul>
028
</nav>
029
</div>
030
</div>
031 </body>
032 </html>
css"
WorldMags.net
Responsive design
112
WorldMags.net
01
Keep it relative
02
001
002
003
004
005
006
007
008
009
010
h2 { font-size: 2.8rem;
margin-bottom: 15px;
font-family: Quando, serif;
color: #a2422a;
}
p {
line-height: 1.45;
margin-bottom: 20px;
}
Breakpoints
04
03
05
06
113
WorldMags.net
Responsive design
Headline text is the most noticable text on a page and any good headline should scale down so it is easy to read on all screens.
FitText.js is a jQuery plugin that does exactly what it says, make text fit, whatever the screen size
margin: 4rem
auto; }
015 }
016
content=width=
device-width, initialscale=1>
Width=device-width
07
007
<link rel=stylesheet
href=css/style.
css>
008 </head>
009
Using FlowType.js
08
</script>
002
<script src=js/flowtype.
js></script>
Max mins
09
<script>
$(body).flowtype({
minimum : 500,
maximum : 1200,
minFont : 12,
maxFont : 40,
114
WorldMags.net
008
fontRatio : 45
});
</script>
009
010
Font ratio
10
11
007
R for root
12
$(html).flowtype
13
Viewport sized
typography
14
h1 {
font-size: 5.9vw;
}
h2 {
font-size: 3.0vh;
}
p {
font-size: 2vmin;
}
FitText.js
15
16
115
WorldMags.net
Responsive design
Do it online
17
CHARACTERS
Print
12pt
Desktop (lg) 1em (16px)
LINE
HEIGHT
1.25em
1.375em
Desktop
1em (16px)
1.375em
60-75
Tablet (lg)
Tablet (sm)
Phone
1em (16px)
1em (16px)
1em (16px)
1.375em
1.25em
1.25em
60-75
60-75
35-40
BODY
FONT SIZE
60-75
60-75
116
WorldMags.net
FlowType.js
Simple Focus is the name of the agency that developed this
plugin which is apt here as the code is both simple and focused.
Variables are set here, but can
be overridden when the plugin
is called in the HTML
001
002
(function($) {
$.fn.flowtype = function(options) {
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
020
021
022
023
024
025
026
027
028
029
030
031
032
033
018
019
WorldMags.net
Responsive design
Create a HTML5
responsive video player
Discover how to create a fully responsive HTML5 video player that
features custom control icons to fit your designs
Everyone knows that video is the best way to keep your audience engaged, however, you now want to
add some of that video goodness onto your fancy responsive website. You scurry off to YouTube and
grab that all-important embed code, lovingly paste it in, only to find that it looks terrible on tablets and
phones. Not only that but the controls are all the same boring icons. Time for a change, in the form of
an HTML5 video player that adapts to your responsive site and fits in with your existing UI with some
custom controls.
Well be basing this tutorial around Bootstrap, for a couple of reasons. The first being that its the
most popular responsive framework out there, so many people will already be using it; the second
reason is that it comes bundled with Glyphicons, which well use to create player controls. You can, of
course, create your icons using standard PNG images if you so wish.
Using this technique we will end up with a video that looks consistent, as the standard HTML5
video player is rendered completely different across different browsers using the browsers built-in
controls, here we make it look identical across all platforms, and respond to smaller devices.
Get set up
bootstrap/3.1.1/js/bootstrap.
min.js>
</script>
01
02
001
002
003
<div class=jumbotron>
<!-- Begin video content -->
</div>
Demonstrate
responsiveness
03
118
WorldMags.net
<div class=container>
<div class=row>
<div class=col-md-6>
<h2>Left Col</h2>
<p>Donec id [] dui.</
</div>
<div class=col-md-6>
<h2>Right Col</h2>
<p>Donec id [] dui.</
</div>
</div>
</div>
Obtain footage
04
001 http://bbb3d.renderfarming.net/
download.html
Embed video
05
support the
004
video tag.
</video>
Video formats
06
Getting responsive
07
By adding in a poster
image, we can display
a title screen that will
disappear when the
user presses Play
119
WorldMags.net
Responsive design
Remove spacing
001
<video width=100% controls
poster=poster.jpg>
08
<style type=text/css>
.jumbotron {
padding: 0;
margin-bottom: 0;
}
</style>
Removing controls
10
11
<script>
$( document ).ready(function()
09
WorldMags.net
Add an ID
12
The controls
13
001
<div class=videoControls>
002
<a href=#
class=btnPlay><span
class=glyphicon glyphiconplay>
</span></a>
003
<div class=videoTime>
004
<span class=current></
span>/<span
class=duration></
span>
005
</div>
006
<a href=#
class=btnMute><span
class=glyphicon glyphiconvolume-up>
</span></a>
007
<a href=#
class=btnFullscreen>
<span class=glyphicon
glyphiconfullscreen></span></a>
008
</div>
Hook up play
14
$(.btnPlay).click(function() {
videoPlayer[0].play();
})
15
121
WorldMags.net
Responsive design
previous step with the below.
001 $(.btnPlay).click(function() {
002
if(videoPlayer[0].paused)
{
003
videoPlayer[0].play();
004
$(.glyphicon-play).
attr(class,
glyphicon glyphiconpause);
005
}
006
else {
007
videoPlayer[0].pause();
008
$(.glyphicon-pause).
attr(class,
glyphicon glyphiconplay);
009
}
010
return false;
011
})
16
001 videoPlayer.on(timeupdate,
function() {
002
$(.current).
text(videoPlayer[0].
currentTime);
003
});
001
Less accuracy
17
$(.current).text(Math.round
(videoPlayer[0].currentTime));
Total time
18
122
WorldMags.net
The Fullscreen button now works across browsers. The user will
be presented with a fullscreen notification when this is activated
001
videoPlayer.
on(loadedmetadata,
function() {
002
$(.duration).text(Math.
round
(videoPlayer[0].duration));
003
});
004
class, glyphicon
glyphicon-volumeup);
008
}
009
});
20
19
001 $(.btnMute).click(function() {
002
if (videoPlayer[0].muted
== false) {
003
videoPlayer[0].muted =
true;
004
$(.glyphicon-volumeup).attr(
class, glyphicon
glyphicon-volumeoff);
005
} else {
006
videoPlayer[0].muted =
false;
007
$(.glyphicon-volumeoff).attr(
Go fullscreen
The final button we need
to hook up is the Fullscreen
button. Going fullscreen works slightly
differently for different browsers, so
there will be two jQuery commands
that will do the exact same thing. Add
this underneath the previous step and
run your browser to see the results.
Press ESC to exit fullscreen.
001
$(.btnFullscreen).on(click,
function() {
002
videoPlayer[0].
webkitEnterFullscreen();
003
videoPlayer[0].
mozRequestFullScreen();
004
return false;
005
});
006
21
001 .videoControls {
002
width: 100%;
003
font-size: 30px;
004
}
005
.videoControls span,
.videoControls div {
006
display: inline-block;
007
}
008
.btnMute, .btnFullscreen {
009
float: right;
010
padding-left: 20px;
011
margin-right: 20px;;
012
}
013
.btnPlay {
014
padding-right: 20px;
015
margin-left: 20px;
016
}
22
123
WorldMags.net
Resources
Essential web design resources
WorldMags.net
Awwwards
Color
365psd.com/
www.awwwards.com
color.hailpixel.com
Behance
COLOURlovers
www.behance.net/
www.colourlovers.com
Apple Watch
concept PSD
watch.janlosert.com/
124
WorldMags.net
Google Fonts
Smashing Magazine
dribbble.com/
www.google.com/fonts/
www.smashingmagazine.com/
Flaticon
www.flaticon.com/
Flat UI Pro
designmodo.com/flat/
HTML5 UP
html5up.net/
Niice
niice.co
Font Squirrel
www.fontsquirrel.com/
Pixeden
www.pixeden.com
Google Developers
Academy
developers.google.com/academy/
Typecast
typecast.com/
Underscores
underscores.me/
Unsplash
unsplash.com/
W3Schools
www.w3schools.com/
WorldMags.net
Resources
Essential web design tools
WorldMags.net
Animate.css
Bitly
http://www.3dcsstext.com/
http://daneden.github.io/animate.css/
www.bitly.com
Adobe Color CC
BigVideo
Bootstrap
https://color.adobe.com/create/
color-wheel/
http://dfcb.github.io/BigVideo.js/
http://getbootstrap.com/
126
WorldMags.net
Can I use
http://caniuse.com/
IOS GUI
www.teehanlax.com/tools
JS Fiddle
www.jsfiddle.net
Codecademy
http://www.codecademy.com/
Lipsum
http://lipsum.com/
CleanCSS
Macaw
http://macaw.co/
Modern.IE
www.modern.ie
Namechk
http://namechk.com/
Normalize.css
http://necolas.github.io/normalize.css/
http://ink.sapo.pt/
Litmus
www.litmus.com
Webflow
www.cleancss.com
Ionic
http://ionicframework.com/
Sublime Text
http://www.sublimetext.com/
www.webflow.com
WorldMags.net
tri Spe
al ci
of al
fe
r
WorldMags.net
Enjoyed
this book?
Exclusive offer for new
Try
3 issues
for just
* This offer entitles new UK direct debit subscribers to receive their first three issues for 5. After these issues,
subscribers will then pay 25.15 every six issues. Subscribers can cancel this subscription at any time. New
subscriptions will start from the next available issue. Offer code ZGGZIN must be quoted to receive this special
subscriptions price. Direct debit guarantee available on request.
** This is a US subscription offer. The USA issue rate is based on an annual subscription price of 65 for 13 issues,
which is equivalent to approx $102 at the time of writing compared with the newsstand price of $194.87 for 13 issues
($14.99 per issue). Your subscription will start from the next available issue.
128
WorldMags.net
In-depth features
About
the
mag
subscribers to
www.imaginesubs.co.uk/wed
Quote code ZGGZIN
Or telephone UK 0844 848 8413 Overseas +44 (0) 1795 592 878
129
WorldMags.net
WorldMags.net
TM
WorldMags.net
facebook.com/ImagineBookazines
twitter.com/Books_Imagine
WorldMags.net
WorldMags.net
WorldMags.net
Introducing HTML
Discover the history behind HTML5 and how it
has developed into a brilliant language
In-depth tutorials
Learn how to add menus, typography and video
players to your site
Cross-browser use
Terminology guides
With all the key terms in one place, understand
the jargon of web design
VOLUME 01
WorldMags.net