Web Designer s Reference

Similar documents
Creating a CSS driven menu system Part 1

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

CSS worksheet. JMC 105 Drake University

Guidelines for doing the short exercises

GIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST

Getting Started with Eric Meyer's CSS Sculptor 1.0

Wanted! Introduction. Step 1: Styling your poster. Activity Checklist. In this project, you ll learn how to make your own poster.

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

CSS: Layout Part 2. clear. CSS for layout and formatting: clear

Using Dreamweaver CS6

CSS Cascading Style Sheets

HTML and CSS a further introduction

Using Dreamweaver CS6

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

Module 2 (VII): CSS [Part 4]

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

BIM222 Internet Programming

Unit 10 - Client Side Customisation of Web Pages. Week 5 Lesson 1 CSS - Selectors

Using Dreamweaver. 6 Styles in Websites. 1. Linked or Imported Stylesheets. 2. Embedded Styles. 3. Inline Styles

The default style for an unordered (bulleted) list is the bullet, or dot. You can change the style to either a square or a circle as follows:

Deccansoft Software Services

CMPT 165 Advanced XHTML & CSS Part 3

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

Hands On: Dreamweaver CS3 NEW SPRY Widgets

READSPEAKER ENTERPRISE HIGHLIGHTING 2.5

CSS مفاهیم ساختار و اصول استفاده و به کارگیری

CSS. Shan-Hung Wu CS, NTHU

Media Stylesheets and Navigation with CSS goodness. Webpage Design

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image

HTML & CSS Cheat Sheet

CSS Tutorial Part 1: Introduction: A. Adding Style to a Web Page (3 options):

Getting your work online. behance.net cargo collective krop coroflot

Reading 2.2 Cascading Style Sheets

CSS Module in 2 Parts

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

5 Snowdonia. 94 Web Applications with C#.ASP

CSS Cascading Style Sheets

**Method 3** By attaching a style sheet to your web page, and then placing all your styles in that new style sheet.

CSS.

Setting a Background Image

How to lay out a web page with CSS

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

Taking Fireworks Template and Applying it to Dreamweaver

Programmazione Web a.a. 2017/2018 HTML5

COMS 359: Interactive Media

Creating a Navigation Bar with a Rollover Effect

CSS Selectors. element selectors. .class selectors. #id selectors

Microsoft Expression Web Quickstart Guide

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

Using Dreamweaver to Create Page Layouts

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

Web Recruitment Module Customisation

Welcome to The Nova Scotia Government. Website Template

Introduction to WEB PROGRAMMING


Before you begin, make sure you have the images for these exercises saved in the location where you intend to create the Nuklear Family Website.

VISA/APCO/STAC 2P61 WEBSITE CREATION Fall Term 2012

Layout with Layers and CSS

ENGINEERING DATA HUB VISUAL DESIGN SPECIFICATIONS VERSION 3. Created: 2/10/2017

CASCADING STYLESHEETS

CSS Styles Quick Reference Guide

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube {

CSS. LBSC 690: Jordan Boyd-Graber. October 8, Adapted. from Dwight VanTuyl s slides. LBSC 690: Jordan Boyd-Graber () CSS October 8, / 57

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

COSC 2206 Internet Tools. CSS Cascading Style Sheets

Zen Garden. CSS Zen Garden

CSS exercise - Part 1

Creating your first website Part 4: Formatting your page with CSS

CSS cont. October 5, Unit 4

Dreamweaver CS3 Lab 2

Introduction to CSS. Part 1: Simple Text Formatting. Source Files for this Exercise are available on the Course Website DW_CSS intro

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

Payne s Dreamweaver CS5 Tutorials

CSS3 Basics. From & CSS Visual Dictionary Learning Curve Books, LLC

CSS: Cascading Style Sheets

Multimedia Systems and Technologies Lab class 6 HTML 5 + CSS 3

8a. Cascading Style Sheet

Web Design and Development Tutorial 03

CSS. M hiwa ahamad aziz Raparin univercity. 1 Web Design: Lecturer ( m hiwa ahmad aziz)

HTML and CSS: An Introduction

Web Publishing Intermediate 2

PUBLISHER SPECIFIC CSS RULES

2. Write style rules for how you d like certain elements to look.

IN4MATX 133: User Interface Software

CSS: The Basics CISC 282 September 20, 2014

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

Dear Candidate, Thank you, Adobe Education

Styles, Style Sheets, the Box Model and Liquid Layout

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations

HTML5: Adding Style. Styling Differences. HTML5: Adding Style Nancy Gill

Stamp Builder. Documentation. v1.0.0

Assignments (4) Assessment as per Schedule (2)

NAVIGATION INSTRUCTIONS

HTML and CSS COURSE SYLLABUS

Transcription:

Web Designer s Reference An Integrated Approach to Web Design with XHTML and CSS Craig Grannell

Graphical navigation with rollovers The final exercise in this chapter concerns navigation with graphical rollovers. The following is a Photoshop mock-up of the navigation bar that we re going to build. (The vertical lines are Photoshop guides, showing the boundary of each button, and are not part of the design.) By conventional methods, you d export eight images from Photoshop two for each link (twelve if you wanted to incorporate an active state). The rollovers would be applied using JavaScript. However, this process has several problems: Updating the rollover graphics requires a lot of work, creating and re-exporting up to a dozen new images. By default, there is a short pause on the hover and active states while the rollover graphic downloads. 158

CREATING NAVIGATION The hover state and active state pauses can be eradicated by using a preload script, but such scripts often don t work well with all browsers. Not everyone surfs the Web with JavaScript turned on. Instead of using JavaScript, we ll use a little CSS and (drumroll) just one image, which is depicted to the right. This image is a single transparent GIF that includes all three link states: link (the default), hover, and active. (What s depicted is the final image, which should be exported in one piece; this should remain a single image file, and shouldn t be chopped into three different files.) What we can do is use this as a background image for navigation links, and use CSS to display the relevant portion of the image, depending on the link action taking place. As with the majority of examples in this chapter, the navigation is marked up as an unordered list. No formatting of the links of any kind is required that s all handled by the CSS. We ve again placed the list within a div tag that has an id value of navigation, so we can create CSS rules that apply only to lists within that specific div. 5 Exercise: Using CSS to create a graphical navigation bar 1. Create the list. As with previous navigation bars created in this chapter, this one consists of a simple unordered list. In a browser, this looks pretty much like you d expect: just a plain, unordered, vertical list. <div id="navigation"> <ul> <li><a href="#">latest news</a></li> <li><a href="#">services</a></li> <li><a href="#">customer support</a></li> <li><a href="#">contact details</a></li> </ul> </div> 2. Style the list. As done previously, browser defaults are removed. #navigation ul { margin: 0px; padding: 0px; list-style: none; 3. Style list items. Items within the list are styled to float left and display inline. The background value includes the location of the rollover image, with additional 159

WEB DESIGNER S REFERENCE: AN INTEGRATED APPROACH TO WEB DESIGN WITH XHTML settings being no-repeat (to stop it from tiling), then left and top, to ensure the relevant portion of the rollover image is seen by default. The margin and padding are set to 0 to override unruly browser defaults. #navigation li { float: left; display: inline; margin: 0px; padding: 0px; background: url(assets/shared/rollover.gif) no-repeat left top; 4. Style the links. Because you haven t set dimensions for the links yet, the backgrounds aren t sitting in the right place. You can fix this by using the following rule, which also deals with the text styles you want to put in place. The padding and height/width settings add up to the dimensions of the area of the background image that you want to show at any one time (185px 30px the size of one of the link states). This is because padding is added to the element width it s not a part of it. If you were to set the width of navigation links to 185px and then add 30px of padding to the left (which is used to indent the text), the links would take up 215px of space. You ll again set display to block, to make the entire container the active link, thereby making this navigation bar work in the normal manner. #navigation a { font: bold 13px Arial, Helvetica, sans-serif; text-transform: uppercase; color: #ffffff; text-decoration: none; display: block; padding: 7px 0px 0px 30px; height: 23px; width: 155px; 5. Style other states. For the hover and active states, you define which portion of the rollover graphic is supposed to be visible. This is done via background-position values. The first of these remains 0px, because you always want to see the image from its far left. The vertical reading depends on where the relevant portion of the image appears in the rollover graphic. 160

CREATING NAVIGATION As you can see, the hover state is 40px from the top and the active state is 80px from the top. This means the image needs to be vertically moved 40px and 80px for the hover and active states, respectively. Therefore, the rules for these states are as follows: #navigation a:hover { background: url(assets/shared/rollover.gif) 0px -40px; #navigation a:active { background: url(assets/shared/rollover.gif) 0px -80px; The hover and active states are shown in the following images. 5 6. Fix for Internet Explorer 5.5 for Windows. We get more into browser hacks in Chapter 12, but we ll briefly outline one here. Internet Explorer 5.5 for Windows gets the box model wrong, incorrectly setting padding and borders within defined element dimensions. The navigation bar currently looks like this in that browser: To deal with Internet Explorer 5.5, the width and height settings need to be the same as the dimensions of the buttons (as opposed to the measurements for compliant browsers, defined in step 4). You can set separate values for Internet Explorer 5.5 by using the box model hack. First, set the width and height for Internet Explorer 5.5 (185px width and 30px height dimensions identical to those of one state of the rollover graphic). Then add the hack and the correct measurements for compliant browsers (as in step 4). #navigation a { font: bold 13px Arial, Helvetica, sans-serif; text-transform: uppercase; color: #ffffff; text-decoration: none; display: block; padding: 7px 0px 0px 30px; height: 30px; width: 185px; voice-family: "\"\""; voice-family:inherit; height: 23px; width: 155px; 161

WEB DESIGNER S REFERENCE: AN INTEGRATED APPROACH TO WEB DESIGN WITH XHTML The hack is the two voice-family rules. Internet Explorer 5.5 stops reading during the first line (it s fooled into thinking the rule terminates due to the quoted curly bracket); compliant browsers recover in the second voice-family line and continue to the end of the rule, with the second set of height and width values overriding the first. Everyone goes home happy well, almost. Internet Explorer 5.5 sometimes also screws up the case of the links, ignoring the text-transform value. A workaround is to create a second #navigation a rule and put the text-transform property/value pair there: #navigation a { text-transform: uppercase; As you can see, this fixes the navigation bar in Internet Explorer 5.5. Sadly, Internet Explorer 5 for Windows cannot deal with text-transform at all, but it manages to display everything else correctly. Still, it s only a minor thing, and that browser s market share is rapidly reducing anyway. As for obsolete browsers (Netscape 4 et al.), hide the CSS and they ll get a perfectly navigable basic list. Again, everyone goes home happy (and I mean it this time!). It s worth noting that many browsers permit text resizing. In such cases, users with extreme setups (text size increased a couple of settings above the default) may end up losing the second word of multiple-word links in this example. This will affect a minority of users, but even so, take care to ensure your navigation makes sense even if the final word is missing. For instance, contact details becoming contact still makes sense, as does help desk becoming help; however, customer support becoming customer could be problematic. Despite this issue, this method is still superior to using graphics for each link: it s easier to update, more accessible, and degrades more gracefully in alternate browsers.