The Wayback Machine - https://web.archive.org/web/20080516225632/http://www.webreference.com/html/tutorial18/2.html


spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / html / tutorials / 18 / 2

index1234

Tutorial 18: CSS Positioning, Part I

Biz Resources
Data Integration Software
Web Hosting
Email Solutions
Developer News
SaaS Tool Offers Custom Database Development
MicrosoftÂ’s Automated Agent: Can We Talk?
Borland Finally Sells CodeGear

Relative positioning

Relative positioning is similar to static positioning, except that relatively positioned boxes can be moved around from where they normally should be. A relatively positioned box appears to be part of the normal flow as far as everyone else is concerned; it takes up space and moves its neighbours away from it to make space for itself, just like all statically positioned boxes, but it is displayed shifted in one or more directions. Here's an example:

P#two {
 position: relative;
 top: 1em;
 left: 1em;
}
<P ID="one">This is box one.</P>
<P ID="two">This is box two.</P>
<P ID="three">This is box three.</P>

The second paragraph is displayed 1em down and 1em to the right of where it should be, but otherwise nothing changes with the layout of the page. (If you're a bit confused, remember that the top and left properties specify the offset from the top edge and the left edge of where the box starts off, so the actual displacement is to the right and down). Relative positioning is a bit like absolute positioning with respect to the element itself. The important difference is, however, that with absolute positioning, the box is completely removed from the rest of the document, and other boxes are placed as if the element never existed; with relative positioning, other boxes behave as if the element was always there.

As you might have guessed, relative positioning is sort of useless most of the time. It is rarely needed to take a box and shove it in some direction just for the fun of it. However, relatively positioned boxes have a very useful property: Just like with absolutely positioned boxes, any absolutely positioned children of theirs will use them as a reference. Also, the top, bottom, left and right properties can all be left at their default value of 0. So, by taking an element, setting the position property to relative and leaving the offsets at zero, the box will be displayed at its original position, still take up space in the document flow, but also define a new set of co-ordinates for its absolutely positioned children.

index1234

http://www.internet.com/



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Copyright 2008 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
How to Create an Ajax Autocomplete Text Field: Part 6 · Software Engineering for Ajax · Perl Pragma Primer
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Using File Virtualization for Disaster Recovery · VoIP Security: SIP—Versatile but Vulnerable · Around the World in 80 Nodes

Legal Notices.

URL: http://www.webreference.com/html/tutorial18/2.html

Produced by Stephanos Piperoglou
Created: February 15, 2000
Revised: February 16, 2000

Morty Proxy This is a proxified and sanitized view of the page, visit original site.