<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CSS Tutorials and CSS Articles &#187; CSS Positioning</title>
	<atom:link href="http://www.cssmaster.co.uk/tag/css-positioning/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cssmaster.co.uk</link>
	<description>CSS tutorials and articles</description>
	<lastBuildDate>Tue, 02 Feb 2010 01:43:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CSS Positioning</title>
		<link>http://www.cssmaster.co.uk/css-positioning</link>
		<comments>http://www.cssmaster.co.uk/css-positioning#comments</comments>
		<pubDate>Mon, 18 Jan 2010 20:22:02 +0000</pubDate>
		<dc:creator>CSS Master</dc:creator>
				<category><![CDATA[CSS Tutorials]]></category>
		<category><![CDATA[CSS Positioning]]></category>

		<guid isPermaLink="false">http://www.cssmaster.co.uk/?p=62</guid>
		<description><![CDATA[Positioning elements on a page can be tricky some times.  There is a lot to remember, but if you can master CSS Positioning then you should be on the right track.
CSS Positioning consists of 4 main declarations:

Static
Fixed
Relative
Absolute

The static position (position:static;) is the default for HTML elements.  It basically means that the element will [...]]]></description>
			<content:encoded><![CDATA[<p>Positioning elements on a page can be tricky some times.  There is a lot to remember, but if you can master <strong>CSS Positioning</strong> then you should be on the right track.</p>
<p><strong>CSS Positioning</strong> consists of 4 main declarations:</p>
<ul>
<li>Static</li>
<li>Fixed</li>
<li>Relative</li>
<li>Absolute</li>
</ul>
<p>The static position (<code>position:static;</code>) is the default for HTML elements.  It basically means that the element will follow the flow of the page and act as you&#8217;d expect them to.</p>
<p><code>position:fixed;</code> is a little different.  The element with this declaration will be placed exactly where you specify and will not move even when the browser window is scrolled.  See the example:<br />
<code>.fixed_div {<br />
&nbsp;&nbsp;position:fixed;<br />
&nbsp;&nbsp;top:0px;<br />
right:10px;<br />
}</code></p>
<p>Next we have relative positioning.  A relatively positioned HTML element is positioned relative to where it would normally be.  Let&#8217;s see the example:<br />
<code>.relative_div {<br />
&nbsp;&nbsp;position:relative;<br />
&nbsp;&nbsp;left:20px;<br />
}</code><br />
This div would be 20 pixels to the right of where it would normally be.  Setting left:-20px; would move it to the left.</p>
<p>An absolutely positioned element is quite different to the others.  The absolutely positioned elements will be placed exactly where you specify on the page, but all other elements on the page will totally ignore it.  Take the following example:<br />
<code>.abs_div{<br />
&nbsp;&nbsp;position:absolute;<br />
&nbsp;&nbsp;top:10px;<br />
}</code><br />
That element will now appear at the top of the page and will (probably) overlap the rest of your content.  </p>
<p>Using <code>position:absolute;</code> it is possible to overlap elements over one another.  Let&#8217;s have a look at the following:<br />
<code>.abs_div{<br />
&nbsp;&nbsp;position:absolute;<br />
&nbsp;&nbsp;top:10px;<br />
&nbsp;&nbsp;width:200px;<br />
&nbsp;&nbsp;height:200px;<br />
&nbsp;&nbsp;background-color:red;<br />
}</p>
<p>.abs_div_over{<br />
&nbsp;&nbsp;position:absolute;<br />
&nbsp;&nbsp;top:20px;<br />
&nbsp;&nbsp;width:200px;<br />
&nbsp;&nbsp;height:200px;<br />
&nbsp;&nbsp;background-color:blue;<br />
&nbsp;&nbsp;z-index:1;<br />
}</code></p>
<p>The above will create 2 boxes at the top of the page, one is red and one is blue.  We have introduced the <code>z-index</code> declaration.  Previously we have used the x and y coordinates (<code>left</code> and <code>top</code>), z-index defines the position of the elements on the page on the z-axis.  The higher the z-index, the further up the pile it is.  The default for z-index is 0, so setting 1 means it will overlap default elements.</p>
<p>When using z-index I suggest always using number in the thousands.  So if you only have one element you want to be placed on top then give it a z-index of 1000.  Doing it this way gives you lots of scope for the future.  In 6 months time you might want to add an element inbetween the two original ones, which if you used z-index:1; would mean recoding, with z-index:1000; you simply add one inbetween.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cssmaster.co.uk/css-positioning/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

