door to my garden Simple CSS resulting in impressive, sophisticated visual effects

Similar documents
Assignments (4) Assessment as per Schedule (2)

Parashar Technologies HTML Lecture Notes-4

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

Getting Started with Eric Meyer's CSS Sculptor 1.0

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

Class 3 Page 1. Using DW tools to learn CSS. Intro to Web Design using Dreamweaver (VBUS 010) Instructor: Robert Lee

Client-Side Web Technologies. CSS Part II

Positioning in CSS: There are 5 different ways we can set our position:

FLOATING AND POSITIONING

CS7026 CSS3. CSS3 Graphics Effects

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

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

CSS THE M\SS1NG MANUAL. David Sawyer McFarland. POGUE PRESS" O'REILLr Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo

Using CSS for page layout

Introduction to HTML & CSS. Instructor: Beck Johnson Week 2

The Benefits of CSS. Less work: Change look of the whole site with one edit

Web Design and Development Tutorial 03

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning

CSS.

CSS Layout Part I. Web Development

COMSC-031 Web Site Development- Part 2

CSS. Shan-Hung Wu CS, NTHU

The Importance of the CSS Box Model

HTML Organizing Page Content

Web Design and Implementation

BORDER IMAGES THE BACKGROUND IMAGE PROPERTIES. Learning Web Design, 5e

Certified CSS Designer VS-1028

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) Horizontal Rule Element

COMM 2555: Interactive Digital Communication / Spring 2018 Lab 9: Basic layout techniques with CSS

When you complete this chapter, you will be able to:

Adding CSS to your HTML

Chapter 3 Style Sheets: CSS

Header. Article. Footer

How to lay out a web page with CSS

READSPEAKER ENTERPRISE HIGHLIGHTING 2.5

CMPT 165: More CSS Basics

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

Perfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

HTML and CSS a further introduction

What is the Box Model?

Create a Web Page with Spry Navigation Bar. March 30, 2010

Viewports. Peter-Paul Koch DevReach, 13 November 2017

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

A pixel is not a pixel. Peter-Paul Koch BlackBerry Jam, 6 February 2012

CSS Cascading Style Sheets

HTML Organizing Page Content

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

Introduction to HTML & CSS. Instructor: Beck Johnson Week 5

EXPLORE MODERN RESPONSIVE WEB DESIGN TECHNIQUES

Web Site Design and Development Lecture 13

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

COMP519 Web Programming Lecture 8: Cascading Style Sheets: Part 4 Handouts

Viewports. Peter-Paul Koch CSS Day, 4 June 2014

Fundamentals of Web Technologies. Agenda: CSS Layout (Box Model) CSS Layout: Box Model. All HTML elements can be considered as a box or a container

Creating Layouts Using CSS. Lesson 9

CSS Handout. CS 4173 Summer about 70 more properties includes all of CSS1 includes properties for non-screen presentation

INFS 2150 Introduction to Web Development

THIRD EDITION. CSS Cookbook. Christopher Schmitt foreword by Dan Cederholm O'REILLY 8. Beijing Cambridge Farnham Koln Sebastopol Taipei Tokyo

INFS 2150 Introduction to Web Development

ORB Education Quality Teaching Resources

Block & Inline Elements

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

FrontPage 2000 Tutorial -- Advanced

A pixel is not a pixel. Peter-Paul Koch MoBeers, 10 April 2012

McMaster Brand Standard for Websites

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) More on Relative Linking. Learning Objectives (2 of 2)

CSS for Page Layout Robert K. Moniot 1

Internet Programming 1 ITG 212 / A

Table Basics. The structure of an table

Tutorial 4: Creating Special Effects with CSS

TAG STYLE SELECTORS. div Think of this as a box that contains things, such as text or images. It can also just be a

Produced by. Web Development. Eamonn de Leastar Department of Computing, Maths & Physics Waterford Institute of Technology

There are 3 places you can write CSS.

CSS Box Model. Cascading Style Sheets

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

Notes - CSS - Flexbox

Tutorial 3: Working with Cascading Style Sheets

Building Page Layouts

Getting Started with CSS Sculptor 3

Stickers! Introduction. Step 1: Colourful coding sticker

Working with Images and Multimedia

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

12/9/2012. CSS Layout

BIM222 Internet Programming


Deccansoft Software Services

Tips and Techniques for Designing the Perfect Layout with SAS Visual Analytics

Web Site Design and Development Lecture 7. CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM

Setting a Background Image

Downloads: Google Chrome Browser (Free) - Adobe Brackets (Free) -

Index. CSS directive, # (octothorpe), intrapage links, 26

WEB PAGE ARCHITECTURE

Appendix D CSS Properties and Values

COMS 359: Interactive Media

Media Types & Media Features

A pixel is not a pixel. Peter-Paul Koch SF HTML5, 6 April 2012

HTML and CSS COURSE SYLLABUS

Transcription:

Patrick H. Lauke, Designer www.csszengarden.com/041 door to my garden Simple CSS resulting in impressive, sophisticated visual effects AN AVID PHOTOGRAPHER, Patrick Lauke prefers to take his own photographs rather than rely on stock images. His Zen Garden entry door to my garden is no exception. Lauke took the photograph used in the stunning body background. Along with photography, Lauke is fascinated by the incidental design concept, also referred to as found art the use of found pieces in artistic endeavors. In the case of door to my garden, Lauke scanned rusted metal pieces that he stumbled across just outside of the building where he works. Along with his photographic skills, these found pieces added to the grungy, faded feel of the design.

Background Savvy While the imagery and typography used for door to my garden certainly go a long way toward creating the dark, brooding mood that the work projects, the effects largely focus on the use of background graphics. Of course, this could be said for many of the Zen Garden designs, but door to my garden illustrates very clearly how positioning backgrounds and defining their scrolling behavior can create a unique look. The main effect is fashioned rather simply and works well across various browsers. Lauke placed a background into the body and fixed it there (FIGURE 1). Then he created and set his content area to the right and overlapping the background image, allowing the content to scroll above the fixed background. Working with background images is a cornerstone of CSS design. It s essential that you understand the properties available and how they can affect and influence the way your elements are styled. BACKGROUND PROPERTIES IN CSS There are six background properties, including the background shorthand property. TABLE 1 shows the properties and what they do. FIGURE 1 The background graphic for the body element. TABLE 1 Background Properties in CSS Property background-color background-image background-repeat background-position background-attachment background Description Defines a background color. Allows you to apply an image to a background. Defines whether your background is repeated or not, and on which axis. Allows you to position the background graphic in relation to the element box. Defines whether your graphic scrolls with the page content or not The shorthand property that combines all of the above properties. DOOR TO MY GARDEN 225

note Many designers define a background color as well as a background image. Colors are managed by the browser and render along with the rest of your CSS, whereas images might take longer to load. Including a color along with a background graphic can create a smoother effect for your visitors. ADDING A BACKGROUND IMAGE AND COLOR To add an image to a background using CSS, you would use the backgroundimage property with a URL value pointing to the image s location, either relative to the CSS file on the local server, or with an absolute URL pointing to another server for cross-site styling: background-image: url(images/my.jpg); To add color to an image, you would use the background-color property with a color value (hex, hex shorthand, RGB, and supported color name values are all acceptable): background-color: black; You can also use the background shorthand property to apply both color and image together along with other properties as Lauke does: background: #000 url(background.png) -30px 0px no-repeat fixed; FIGURE 2 The background image remains fixed as the content scrolls. This is why the very bottom of the content and the background graphic can be seen at the same time. Another feature of the background-color property that is used frequently in door to my garden is the transparent value. This allows an element s background to show whatever is behind it. Transparency is used with links in this design, for example: a { color: #eee; background: transparent; text-decoration: none; ATTACHING BACKGROUNDS The background-attachment property takes a value of either scroll or fixed. The default value in browsers is scroll, where the background image scrolls along with the content. By fixing the image, you can achieve the effect that Lauke did. The background does not move as the content itself scrolls (FIGURE 2). The photo Lauke took is placed into the body s background and fixed: background: #000 url(background.png) -30px 0px no-repeat fixed; 226 CHAPTER 6 / SPECIAL EFFECTS

POSITIONING BACKGROUNDS The background-position property controls where a background image is placed, in relation to the parent element. This property takes percentage, length, and keyword values. Each value has two potential positions. If two values are used, the first is horizontal and the second is vertical: background-position: 10px 20px; If only a single value is specified, it is applied to the horizontal position and the vertical position is assumed to be 50 percent or center. This declaration would place the image 10 pixels on the horizontal axis and 20 pixels along the vertical. In the background position example from Lauke s CSS, you ll notice that the positioning uses a length value of pixels: background: #000 url(background.png) -30px 0px no-repeat fixed; tip You do not need to use a unit if you re setting a value to 0. This is true with any CSS property. A value of 0 is implicit. So, another way to have approached this particular declaration would have been to write background: #000 url(background.png) -30px 0 no-repeat fixed; FIGURE 3 The image in normal flow. An item of interest is the negative value of -30px. This is a legitimate value for background positions and offsets the background image 30 pixels horizontally to the left, instead of to the right as positive values normally position the background. The 0-pixel value sets the vertical position of the image so that it s flush with the top margin of the containing element in this case, the body element. FIGURES 3 and 4 allow you to compare the left position of the background image, first in relation to the browser, then styled using the negative horizontal value. FIGURE 4 Visualizing the negative value in the background s position. CONTROLLING BACKGROUND TILING Using presentational HTML, there is no way to control the way in which backgrounds repeat the default is to tile them along both the x and y axes. Fortunately, CSS gives us far more control via the background-repeat property. This property allows for these values: repeat-x so the background only tiles along the horizontal axis; repeat-y so the background only tiles along the vertical axis; no-repeat so the graphic doesn t repeat; and repeat, which is the default value and specifies that the graphic repeats along both axes. Lauke has used the no-repeat value in his background shorthand: background: #000 url(background.png) -30px 0px no-repeat fixed; DOOR TO MY GARDEN 227

This ensures that the background image doesn t tile. In all backgrounds in door to my garden, there is consistently no background repetition, though other instances are controlled through further style rules not shown here. FIGURE 5 The padding is what sets the container section 470 pixels from the left. Layout Choices To get the 300-pixel-wide #container, which is offset from the left of the viewport by 470 pixels, Lauke set a 470-pixel padding into the body: padding: 0 0 0 470px; Remember that the order for shorthand properties in padding and margins is top, right, bottom, left. All of these values have been set to 0 (you ll note that here, Lauke chose not to include the length value for 0s) except for the left value, which pads the left of the canvas with 470 pixels of space (FIGURE 5). The container is styled with a background image, a color, and a width only: #container { background: #000 url(bottom_corner.png) no-repeat bottom right; color: inherit; width: 300px; Using the Web Developer extension for Mozilla and Firefox, you can turn on the outline block element feature and also get the class and ID information for each element. FIGURE 6 demonstrates the way in which styles have been applied to elements within the #container division. FIGURE 6 Using the Web Developer extension, you can see the styles as applied to elements within the #container division. Additional Style Effects door to my garden relies on mostly uncomplicated and hack-free CSS, so one of the more challenging aspects Lauke faced was managing the menu and flower image that appears to accompany it (FIGURE 7). The framed menu was hard to get working consistently across various browsers. The menu portion itself wasn t the real challenge. Lauke created a container for the #linklist ID and built the navigation by styling each element with a 228 CHAPTER 6 / SPECIAL EFFECTS

different piece of the background that forms the frame. But getting that flower image floating out of the framed box and over the background was more complicated. #linklist2>#lselect { background: url(flower.png) no-repeat top left; margin-left: -65px; padding-left: 80px; min-height: 150px; Using a child selector, this CSS works in Mozilla, Opera, and Safari browsers. In order to get acceptable results in Internet Explorer, Lauke used one of the extra divs in the Zen Garden markup to absolutely position the flower image: #extradiv1 { position: absolute; top: 165px; left: 142px; background: url( flower.png ) no-repeat top left; width: 115px; height: 150px; At this point, fully compliant browsers are getting both styles. So Lauke had to go one step further and hide this particular style from those browsers already supporting the original #linklist2>lselect style: body>#extradiv1 { display: none; FIGURE 7 The menu and flower image, outlined so that you can see the elements in question. tip You can get the Web Developer extension free from chrispederick.com (www. chrispederick.com/work/firefox/ webdeveloper/index.php). Voilà! The flower and menu are visible and behave alike in modern browsers. Great Style, Simple CSS It s clear that the beauty of door to my garden is due to unique imagery, typography, and the thoughtful placement of elements. While at first glance the design appears complicated, the reality is that it uses simple CSS to achieve the majority of its effects, with only one true workaround to ensure compatibility. DOOR TO MY GARDEN 229