web design

45
WEB DESIGN Multimedia and Web

Upload: ruby-lamb

Post on 31-Dec-2015

17 views

Category:

Documents


1 download

DESCRIPTION

Web design. Multimedia and Web. Today’s Objectives. Quick review selector types Layout and positioning. Selectors. Types of selectors. Tag or HTML Selectors: Page-Wide Styling p {color: #333333;} Class Selectors: Pinpoint Control .myclass {color: #333333;} - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Web design

WEB DESIGN

Multimedia and Web

Page 2: Web design

Today’s Objectives

Quick review selector types Layout and positioning

Page 3: Web design

SELECTORS

Page 4: Web design

Types of selectors

Tag or HTML Selectors: Page-Wide Stylingp {color: #333333;}

Class Selectors: Pinpoint Control.myclass {color: #333333;}

ID Selectors: Specific Page Element#main-nav {color: #333333;}

Group Selectors h1, h2, h3, p, div {color: #333333;} Pseudo class a:link {} Pseudo elements p:first-letter {} Attribute a[href^="http://"] { color : yellow; }

Page 5: Web design

Pseudo-Classes

a:link | a:link { color : #EFEFEF; } a:visited | a:visited { color :

#CCCCCC; } a:hover | a:hover { color : # F33333; } a:active | a:active {color : #B2F511;}

Hover: (these will also work) h1:hover { color : #FFFFFF; } .hiLite:hover { color : #FFFFFF; }

Page 6: Web design

Structural pseudo-classes

Beginning with second item select every 4th items

Source: McFarland, D.S. (2009), CSS: The missing manual, O’Reilly.

Page 7: Web design

Pseudo-elements

:first-letter – p:first-letter { font-size : 2em;

font-weight: bold;color: red;}

:first-line –p:first-line { font-size : 2em;

font-weight: bold;color: red;}

Lorem ipsum dolor sit

amet, consectetuer adipiscing elit. Duis non ipsum quis sapien rhoncus vehicula.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis non ipsum quis sapien rhoncus vehicula.

Page 8: Web design

Attribute Selectors | ^ and $Format external links:

a[href^="http://"] { color : yellow; }

^ - begins withAny link that begins with “http://” is yellow

a[href$=".zip"] { color : green; }$ - Ends withAny link URL that ends with “zip” is green.

Page 9: Web design

Attribute Selectors | *

img[src*="Ire"] {border : solid 5px green;}

<img src="banner_Ire.png“ />

<img src="banner.png“ />

Page 10: Web design

LAYOUTS | FLOATS |POSITIONING

Page 11: Web design

HTML Tree

<html>

<head>

<title>My Web Page</title>

</head>

<body>

<h1>Main Topic</h1>

<p>

A web page about the days of the week, specifically<strong>Tuesday.</strong>

</p>

</body>

</html>

Remember the document flow/tree

(DOM)

Page 12: Web design

HTML Tree Hierarchy

<html>

<head> <body>

<title> <p><h1>

<strong>

Ancestor to all tags

Ancestor to h1, p, span

Siblings

Child of <p>

Descendent of <html>

Descendent of <html> and <head>

Page 13: Web design

HTML Tree

<html>

<head>

<title>My Web Page</title>

</head>

<body>

<h1>Main Topic</h1>

<p>

A web page about the days of the week, specifically<strong>Tuesday.</strong>

</p>

</body>

</html>

Page 14: Web design

HTML Tree

<html>

<head>

<title>My Web Page</title>

</head>

<body>

<h1>Main Topic</h1>

<p>

A web page about the days of the week, specifically<strong>Tuesday.</strong>

</p>

</body>

</html>

Normal Document Flow

Page 15: Web design

HTML Tree

<html>

<head>

<title>My Web Page</title>

</head>

<body>

<h1>Main Topic</h1>

<p>

A web page about the days of the week, specifically<strong>Tuesday.</strong>

</p>

</body>

</html>

Elements (tags) create boxes - stack on top of

each other

Page 16: Web design

<div id=“wrapper”>

<header id=“banner”> </header>

<nav id=“main-nav”> </nav>

<div id=”main-content”> </div>

<footer id=“site-info”> </footer>

</div>

NORMAL DOCUMENT FLOW

Page 17: Web design

HEADER id=“banner”

NAV id=“main-nav”

DIV id=“main-content”

FOOTER id=“site-info”

Div id=“wrapper”

Normal Flow

<html> <body>

<body><html>

Page 18: Web design

1. BANNER

2. NAVIGATION

3. CONTENT

1.BANNER

2 3.CONTENT

FLOAT LEFT

L

Normal Flow

Page 19: Web design

1. BANNER

2. NAVIGATION

3. CONTENT

1.BANNER

23.CONTENT

FLOAT RIGHT

R

Normal Flow

Page 20: Web design

1. BANNER

2. NAVIGATION

3. CONTENT

1.BANNER

43.CONTEN

T

FLOAT Left & Right

R4. EVENTS

2

L L

Normal Flow

Page 21: Web design

HEADER id = banner

NAV id = main-nav

DIV id = main-content

FOOTER id = site-info

DIV id = wrapper

FLOAT LEFT

Page 22: Web design

HEADER id = banner

NAV id = main-nav

DIV id = main-content

FOOTER id = site-info

DIV id = wrapper

FLOAT LEFT

<style>#wrapper,#banner,#main-nav, #main-content, #site-info {padding:10px;}

#wrapper {border:1px solid #0C0;background-color:#F90;}

#banner {border:1px solid #0C0; background-color:#099;}

#main-nav { border:1px solid #099; background-color:#069;width:200px; float:left;

}

#main-content { border:1px solid #03F; background-color:#09C;margin-left:222px;}

#site-info {border:1px solid #933; background-color:#CC9;}

</style>

Page 23: Web design

HEADER id = banner

NAV id = main-nav

DIV id = main-content

FOOTER id = site-info

DIV id = wrapper

FLOAT LEFT

<style>#wrapper,#banner,#main-nav, #main-content, #site-info {padding:10px;}

#wrapper {border:1px solid #0C0;background-color:#F90;}

#banner {border:1px solid #0C0; background-color:#099;}

#main-nav { border:1px solid #099; background-color:#069;width:200px; float:left;

}

#main-content { border:1px solid #03F; background-color:#09C;margin-left:222px;}

#site-info {border:1px solid #933; background-color:#CC9;}

</style>

With positioning, can place boxes anywhere on screen.

Page 24: Web design

POSITIONING

Page 25: Web design

Positioning

CSS position property lets you control how and where a web browser displays particular elements.

CSS offers four types of positioning: Absolute Relative Fixed Static

Page 26: Web design

Absolute Positioning

Absolute : determine element’s location by specifying a left, right, top, or bottom position in pixels, ems, or percentages.

Element moves out of the normal flow of the page as determined by the HTML.

Page 27: Web design

Detached from document flow. Other elements fill-in the space left by an absolutely positioned element.

Float and absolute or fixed positioning can’t work together on the same element.

Absolute Positioning

Page 28: Web design

1. BANNER

2. NAVIGATION

3. CONTENT

4. EVENTS

1. BANNERposition: absolute; left:10px;

top:100px

3. CONTENT

4. EVENTS

Content below absolute positioned element moves up to fill space.

Absolute PositioningNormal doc flow.

Page 29: Web design

Absolute Positioning

Absolutely positioned element is placed relative to the boundaries of its closest ancestor.

When you create element (DIV) with absolute positioning, any absolutely positioned elements inside

that element are positioned relative to it’s top, bottom, left, and right edges.

Page 30: Web design

Browser<div id=“wrap”> no positioning

- 150px -

<div id=“nav”> position: absolute;

left:150px;

Create element (DIV) with absolute positioning, any absolute positioned elements inside that element are positioned relative to it’s top, bottom, left, and right edges.

Page 31: Web design

Browser<div id=“wrap”> no positioning

- 150px -

<div id=“nav”> position: absolute;

left:150px;

Content below fills vacated space.

Page 32: Web design

Browser<div id=“wrap”> absolute or relative

<div id=“nav”> position: absolute;

left:150px;

- 150px -

Page 33: Web design

Relative positioning

Relative. Element placed relative to its current position in the normal document flow.

Other elements do NOT fill in the space left in the document flow.

Left:250px

This space does not get filled in.

Page 34: Web design

Relative positioning

A benefit of relative positioning is to set a new point of reference for absolutely positioned elements that are nested inside it.

Relative positioning creates a positioning context for nested elements (tags).

Page 35: Web design

Relative positioning

Example

Set position of the <p> tag to relative, Any absolute positioning you apply to

the <img> tag inside the <p> tag is relative to the four edges of the <p> tag, not the browser window.

Page 36: Web design

Relative positioning

Here’s what the CSS looks like:

p { position: relative; }

p img {position: absolute;top: 0;right: 55px;}

Page 37: Web design

Positioning Rules

A tag is positioned relative to the browser window if it has an absolute position and it’s not inside any other tag that has absolute, relative, or fixed positioning applied to it.

A tag is positioned relative to the edges of another element if it’s inside (child) another tag with absolute, relative, or fixed positioning.

Page 38: Web design

Fixed Positioning

Fixed. Element is locked into place on the screen.

When scrolling, fixed elements remain onscreen.

Useful for creating a fixed sidebar.

Page 39: Web design

Static Positioning

Static. Normal positioning method – what an element appears in the normal document flow.

Page 40: Web design

Setting Positioning Values

Display area of a web browser window has top, bottom, left, and right edges.

Each of the four edges has a corresponding CSS property: top, bottom, left, and right.

Don’t need to specify values for all four edges.

Two are usually enough to place an item on the page.

Page 41: Web design

Setting Positioning Values

Any of the valid CSS measurements—pixels, ems, percentages, etc. can be used.

You can also use negative values for positioning.

Page 42: Web design

Setting Positioning Values

Position element from the top and left edges of window:

#banner { position: absolute;left: 100px;top: 50px;width: 760px;}

Page 43: Web design

Setting Positioning Values

Position the banner 100 pixels from the right of the window

#banner { position: absolute;right: 100px;top: 50px;width: 760px;}

Page 44: Web design

Z-index

This stacking of elements takes place on what’s called the z-index.

.logo1 {position: absolute;z-index: 0;left: 810px;top: 10px;

}

Page 45: Web design