16
HTML & CSS Basics III class three: CSS review, backgrounds, font formatting, the box model

Class three: CSS review, backgrounds, font formatting, the box model

Embed Size (px)

Citation preview

Page 1: Class three: CSS review, backgrounds, font formatting, the box model

HTML & CSS Basics IIIclass three: CSS review,

backgrounds, font formatting, the box model

Page 2: Class three: CSS review, backgrounds, font formatting, the box model

…so let’s attach our CSS

<head><link rel="stylesheet" href="cafe.css" /></head>

Page 3: Class three: CSS review, backgrounds, font formatting, the box model

Backgrounds

background-color Hex (#ff0000) RGB (rgb(255,0,0)) Name (red)

try it:body {

background-color: #F1F2E4;}

Page 4: Class three: CSS review, backgrounds, font formatting, the box model

Backgroundsbackground-image url(‘image.jpg’)

background-repeat repeat (default), repeat-x, repeat-y, no-repeat

background-position left, center, right, top, center, bottom x% y% (0% 0% default) xpos ypos

background-attachmentscroll (default), fixed

try it:#menu {

background-image:url('images/fabric_texture.jpg');}

Page 5: Class three: CSS review, backgrounds, font formatting, the box model

Textcolor hex, RGB, or name

text-align left (default), center, right, or justify

try it:h1 {

color: #B55109;text-align:center;

}

Page 6: Class three: CSS review, backgrounds, font formatting, the box model

Texttext-decoration none (default), overline, line-through, underline,

blink

text-transform none (default), uppercase, lowercase, capitalize

try it:a {

text-decoration:none;text-transform:uppercase;color: #66839E;}

Page 7: Class three: CSS review, backgrounds, font formatting, the box model

Fontfont-size default size is 16px px, cm, em, %, xx-small, x-small, small, medium, large, x-large, xx-large,

smaller, larger

font-weight normal(default), bold, bolder, lighter, 100-900

try it:h1 {

color: #B55109;text-align:center;font-size: 4em;font-weight: 400;

}

h2, h3 {color: #B55109; font-size:2em;font-weight:400;

}

Page 8: Class three: CSS review, backgrounds, font formatting, the box model

Fontfont-family syntax= font-family:individual, family; families include: serif, sans-serif, monospace, cursive,

fantasy

font-style normal(default), italic, oblique

try it:body {

background-color: #F1F2E4;font-family: "Trebuchet MS", Helvetica, Tahoma, sans-serif;}

Page 9: Class three: CSS review, backgrounds, font formatting, the box model

Font

@font-face Allows you to use any font, provided

it’s hosted somewhere on the web. Many options: Font Squirrel, Google

web fonts, TypeKit

try it:TOO MUCH TEXT! Let’s just copy and

paste.

Page 10: Class three: CSS review, backgrounds, font formatting, the box model

Font@font-face Needs multiple file formats to work in multiple

browsers:@font-face {

font-family: 'bebasregular';src: url('webfont.eot'); /*>IE9*/src: url('webfont.eot?#iefix') format('embedded-opentype'), /*<IE8*/

url('webfont.woff') format('woff'), /*emerging standard*/

url('webfont.ttf') format('truetype'), /*most browsers besides IE and iPhone*/

url('webfont.svg') format('svg'); /*iPhone and iPad*/font-weight: normal;font-style: normal;

Page 11: Class three: CSS review, backgrounds, font formatting, the box model

Font@font-face Once this declaration is in place, refer to your new fonts

using font-family

try it:body {

background-color: #F1F2E4;font-family: KameronRegular, ''Times New Roman'', serif;}

In h2, h3:font-family: OstrichSansBlack, Verdana, Geneva, sans-serif;

In h1:font-family: OstrichSansBlack, Verdana, Geneva, sans-serif;

Page 12: Class three: CSS review, backgrounds, font formatting, the box model

Font@font-face Once this declaration is in place, refer to your new fonts using font-

family

try it:footer {

font-family: OstrichSansBold, Verdana, Geneva, sans-serif;font-size: 2em;text-align: center;}

nav ul {font-family: OstrichSansBold, Verdana, Geneva, sans-serif;font-size: 2em;}

h1 span {font-family: OstrichSansBold, Verdana, Geneva, sans-serif;}

Page 13: Class three: CSS review, backgrounds, font formatting, the box model

Span? What?

<span> is an HTML tag which allows you to just group some elements together. It doesn’t mean anything!

try it:<h1>Sam <span>&amp;</span>

Sally's <span>Cafe</span></h1>

Page 14: Class three: CSS review, backgrounds, font formatting, the box model

More Span!Let’s use <span> to format the copyright in

the footer.

html:<footer>

<span>&copy; </span>2014...

css:footer span {

font-family: KameronRegular, ''Times New Roman'', serif;

}

Page 15: Class three: CSS review, backgrounds, font formatting, the box model

If there’s not a natural element, break html up with <div>

<div>, like <span>, doesn’t mean anything. It’s meant to divide up the page into related parts.

Try it:</nav><div id="content">…</div><footer>

Page 16: Class three: CSS review, backgrounds, font formatting, the box model

the parts of a boxthe webpage

heig

ht

content

width

border

padding

margin