<?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>Geek Gumbo &#187; CSS</title>
	<atom:link href="http://www.geekgumbo.com/category/webdev/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekgumbo.com</link>
	<description>A potpourri of Web Developmemt, Linux, and Windows tidbits and observations</description>
	<lastBuildDate>Sun, 05 Sep 2010 14:14:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Styling Links with CSS</title>
		<link>http://www.geekgumbo.com/2010/06/12/css-styling-links/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=css-styling-links</link>
		<comments>http://www.geekgumbo.com/2010/06/12/css-styling-links/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 21:54:00 +0000</pubDate>
		<dc:creator>dale</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=1611</guid>
		<description><![CDATA[One aspect of CSS styling that some times can be confusing is styling links. This is because they are governed by both pseudo elements and specificity. Let&#8217;s take a closer look. Pseudo elements are tags that CSS recognizes, that attach to HTML tags, but are not put directly into the HTML markup. We see this [...]]]></description>
			<content:encoded><![CDATA[<p>One aspect of CSS styling that some times can be confusing is styling links.  This is because they are governed by both pseudo elements and specificity.  Let&#8217;s take a closer look.</p>
<p>Pseudo elements are tags that CSS recognizes, that attach to HTML tags, but are not put directly into the HTML markup.  We see this most often used with hyperlinks and anchor tags.</p>
<p>CSS uses four pseudo elements to style links:</p>
<p><span style="color: #993366;">:link</span> The link pseudo tag is used for all links on the page that point to other locations that have NOT been visited. Here&#8217;s an example</p>
<pre class="brush:html"><!-- Normal link styling before any events -->
a:link {
color: blue;
text-decoration: none;
}</pre>
<p>Normally a link is underlined by your browser.  If you don&#8217;t want your link underlined you can shut the underline off with the text-decoration: none;.</p>
<p>The next tag is &#8220;<span style="color: #993366;">:visited</span>.&#8221; These are sites that you have clicked on, visited, and then have returned to your page.</p>
<pre class="brush:html">
<!-- styling a link that you have visited -->
a:visited {
color: orchid;
}</pre>
<p>Note the pseudo classes, &#8221; a:visited&#8221; for example,  is attached directly to the html tag with a colon, no spaces.</p>
<p>&#8220;<span style="color: #993366;">:hover</span>&#8221; This styling will happen when your pointing device, or mouse, moves over the tag.  You do not have to actually click on the tag for hover to work.  This tags is used with the &#8220;img&#8221; tag to swap images when your mouse rolls over a picture.  You can use this with other tags, like a table row.</p>
<pre class="brush:html">
<!-- syling a table row with css on hover  -->
tr:hover {
background-color: yellow;
}
</pre>
<p>Finally, we have &#8220;<span style="color: #993366;">:active</span>&#8221;   This styling is applied when an element has focus. Typically this is used with forms when you click in a form input box, or tab to it,  to type your name for example.</p>
<pre class="brush:html">
<!-- styling a text input box when active -->
input:active { background-color: orange; }
</pre>
<p>Those are the basics, now let&#8217;s get a little more specific, pun intended, and why some people&#8217;s pseudo styling doesn&#8217;t work the way they thought they had styled their tags. It turns out that pseudo tags all have the same specificity in CSS.  That means that:</p>
<pre class="brush:html">
 a:link {color: blue;}
 a:active {color: orange;}
 a:hover {color: yellow;}
 a:visited {color:orchid;}
</pre>
<p>All are equal in terms of specificity in CSS.  And according to the Cascade Styling rules, if specificity is equal, the last styling gets the nod.  In the above order, if any of your links become visited, then, from then on, your link will show only the orchid color.  Not quite what you want, so visited needs to be listed higher up, first or second.  </p>
<p>In order for your links to perform properly, like you expect, they need to be listed in the correct order which is:</p>
<pre class="brush:html">
 a:link {color: blue;}
 a:visited {color: orchid;}
 a:hover {color: yellow;}
 a:active {color: orange;}
</pre>
<p>Link and Visited are mutually exclusive, in terms of which applies, so they can be listed in either first or second order interchangeably.  Again: visited, link, then hover, and finally active: vlha, or &#8220;Very Lean Hungry Apes&#8221; as a memory aid.  Enjoy, and good CSSing to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2010/06/12/css-styling-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Elastic CSS Framework &#8211; a Review</title>
		<link>http://www.geekgumbo.com/2010/05/10/the-elastic-css-framework-a-review/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=the-elastic-css-framework-a-review</link>
		<comments>http://www.geekgumbo.com/2010/05/10/the-elastic-css-framework-a-review/#comments</comments>
		<pubDate>Mon, 10 May 2010 05:48:32 +0000</pubDate>
		<dc:creator>dale</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=1396</guid>
		<description><![CDATA[CSS Frameworks help by reducing the amount of work you need to set up an initial site when integrating CSS and XHTML to form a nice looking web page that is compatible across all browsers.  It seems like with every new web site you go through the same process over and over again,  and a [...]]]></description>
			<content:encoded><![CDATA[<p>CSS Frameworks help by reducing the amount of work you need to set up an initial site when integrating CSS and XHTML to form a nice looking web page that is compatible across all browsers.  It seems like with every new web site you go through the same process over and over again,  and a framework can  save time.</p>
<p>I had evaluated CSS Frameworks about a year and a half ago notably Yahoo&#8217;s YUI grids, Elements, Blueprint, Tripoli, Hartija, and BlueTrip.  Elements included a folder systems for the entire site.  BlueTrip is Tripoli and Blueprint combined.  YUI, Blueprint, and BlueTrip feature a grid system to make multiple columns easier to implement.  Hartija is for printing.  Tripoli is a minimal framework that features a reset and font styling, but no column grids.</p>
<p>The outcome of the above review was I decided I had no problem making grids in CSS.  These frameworks seemed to add a lot of bloat with a learning curve.  I did not need a folder set up. I needed to have browser compatibility handled by Tripoli, and needed printing, handled by Hartija.  That&#8217;s what I settled on and use with all my sites.</p>
<p>I searched for CSS Frameworks and found some new ones I missed in my earlier survey:  &#8220;960&#8243; was new and looked nice, then there was jQuery UI framework, and YAML.  I didn&#8217;t jump to  look at any of these until I ran across a framework called Elasticss or Elastic CSS.</p>
<p>What hooked me on taking a closer look at Elastic.  A very simple grid system, elastic or fixed width columns, built-in event handling, and elastic and fixed height columns.  The last two features is what hooked me, no other framework I saw offered built in event handling and variable height columns, except maybe jQueryUi, which looked a lot more complicated to implement.  I decided to give <a title="Elastic CSS" href="http://elasticss.com/">Elastic</a> a look.</p>
<p>I downloaded it, set up an HTML page, and started to link in their CSS and Javascript libraries.  And that&#8217;s where I started having trouble.</p>
<p>I just could not get the thing to work initially.  I had problems with understanding how to set up the html tags to make the framework work.</p>
<p>The elastic site had documentation, but it had problems.  It seemed complete, but what was wrong, was the developer had changed the syntax from one release to another and had some documentation one way, and some the other, which made things very confusing when the site didn&#8217;t work.</p>
<p>The way I made it work was to look at their demo pages, view the page source in the browser, and copy there tags to my html page.</p>
<p>After I got everything working, I had mixed results.  On the plus side, their column system is excellent, and is not really a grid system. It features English language intuitive syntax. It is the easiest column system I have run across.  Columns are very flexible and easily re-size across the page and can be multilayer.   The ease of making columns, with intuitive English tags, alone would make me consider using this framework.</p>
<div id="attachment_1416" class="wp-caption aligncenter" style="width: 560px"><a href="http://www.geekgumbo.com/wp-content/uploads/2010/05/elastic4.png"><img class="size-full wp-image-1416" title="elastic4" src="http://www.geekgumbo.com/wp-content/uploads/2010/05/elastic4.png" alt="" width="550" height="643" /></a><p class="wp-caption-text">Html file showing Elastic CSS English language column syntax</p></div>
<p>The event handling was accomplished by linking in jQuery with the framework.  I was happy with this, since once jQuery was linked in, I could use it on the site, and with other plug-ins.  It did all the normal framework things well, like layout, browser reset, printing, and font styling.</p>
<p>On the minus side, I could not get the variable height columns working, and this was the main reason I evaluated the framework, and I tried.  I figured maybe a piece of the code had an error.</p>
<p>I put all the CSS through a validator and found two of the six CSS files did not validate, nor did the javascript come up clean.  I was not sure by the error, whether a  &#8220;*font-size&#8221;  tag, for example, which throws an error in the validator, was somehow part of the framework, or simply should be taken out and made &#8220;font-size.&#8221;</p>
<p>I was almost already to far into it when I wondered if I had the absolute latest version, I decided to download the entire project located on github.  Did I mention how much I love git and github.</p>
<p>I opened the project, used the latest files, and still could not get the heights to adjust.  Bummer.</p>
<div id="attachment_1414" class="wp-caption aligncenter" style="width: 560px"><a href="http://www.geekgumbo.com/wp-content/uploads/2010/05/elastic51.png"><img class="size-full wp-image-1414" title="elastic51" src="http://www.geekgumbo.com/wp-content/uploads/2010/05/elastic51.png" alt="" width="550" height="276" /></a><p class="wp-caption-text">The resulting web page from the above Html file with CSS styling.</p></div>
<p>Elastic CSS looks to be about a year and a half old from its inception.  My hope is the developers will keep working, I think they could eventually have something special.  Right now, however, I don&#8217;t think Elastic is quite there yet.</p>
<p>Here&#8217;s what I want from a CSS Framework, and so far, I haven&#8217;t found one that has it all.  If anyone knows of a framework with these features please let me know.  An easily understood and implemented multiple column system that handles elastic, jello, and fixed layouts, the same identical page in all browsers, print formatting, vertical column flexibility to eliminate &#8220;faux columns,&#8221; and make columns have equal heights, the ability to style layouts, fonts, and colors easily across the site in separate css files.  jQuery integrated with the framework.  Finally, all of this imported with one line into a skeleton xhtml file that is a template to produce your page, and when I unzip the file and place it on my server, everything is linked up.  Now that would save  me time and is worth the cost of admission.</p>
<p>In thinking about what I&#8217;m asking for, it doesn&#8217;t seem that unattainable, what it takes is someone with some spare cycles to put it together, or for the Elastic developers to polish their already nice framework to get the heights to work out of the box.   It also would be nice if everything validated.   I have my fingers crossed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2010/05/10/the-elastic-css-framework-a-review/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Capitalize the first letter of a paragraph with CSS</title>
		<link>http://www.geekgumbo.com/2010/04/25/capitalize-the-first-letter-of-a-paragraph-with-css/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=capitalize-the-first-letter-of-a-paragraph-with-css</link>
		<comments>http://www.geekgumbo.com/2010/04/25/capitalize-the-first-letter-of-a-paragraph-with-css/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 16:48:03 +0000</pubDate>
		<dc:creator>dale</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=1129</guid>
		<description><![CDATA[.storycontent #cssfirst p:first-letter { font-size: 300%; font-family: garamond, bodoni, curly, times, serif; color: orange; padding-right: 1px; position:relative; margin-left: -26px; } Books twenty or thirty year ago use to have the first letter of a chapter set off differently than the rest of the lettering in the chapter.  It was a single letter with flowery font [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">
.storycontent #cssfirst p:first-letter {
font-size: 300%;
font-family:  garamond, bodoni, curly, times, serif;
color: orange;
padding-right: 1px;
position:relative;
margin-left: -26px;
}
</style>
<div id="cssfirst">
<p>
Books twenty or thirty year ago use to have the first letter of a chapter set off differently than the rest of the lettering in the chapter.  It was a single letter with flowery font that was much larger than the rest of the font on the page.  Publishers called them drop caps.  You remember those, don&#8217;t you?</p>
<p>With the advent of the Internet, good punctuation and grammar has changed from those old days.  I think email and web url addresses have changed a lot of the way we punctuate and write.  Here are some of the things, I&#8217;ve noticed, that are in display in this article.</p>
<p>Paragraphs are now separated by a space, they didn&#8217;t use to be in books.  This makes it easier to read on the screen.  It use to be, probably because the lines were not separated, that all paragraphs started out with the first line of the text indented, they don&#8217;t now.  Fonts use to be mostly serifs with flowery curls on the letters in books, the web uses mostly sans-serif, without the flowery curls, for easier reading.  The most prevalent font being verdana.</p>
<p>And then we come to punctuation, when you end the sentence with a web address, there&#8217;s always the question of, do you end the sentence with a period, that may interfere with the web address.  This happens with other technical jargon.  If you want to show the proper syntax of how to write a function or command, you don&#8217;t want to use a period that may be confused with part of the syntax, so you just leave the period off, and start a new sentence with a capital letter.  The web has indeed changed the look of our writing.</p>
<p>The designers of CSS wanted to accommodate every one, so they even made allowances for those dusty old scholarly types that, though ancient cities, still wrote with the &#8220;King&#8217;s English.&#8221;  I&#8217;ve found that, like all things in life,  &#8220;What comes around, goes around,&#8221; and things like paragraph indents, and drop caps now make a web site look different and refreshing.  They give you a different look that in many ways make the text easier to read.</p>
<p>Let&#8217;s talk about how to put drop caps on your web site.  There&#8217;s such a thing in CSS called pseudo elements.  Currently with CSS2 there are four of them.  Pseudo elements are called pseudo, because they&#8217;re not part of your standard html markup.  There is no &#8220;first letter&#8221; html tag, just the &#8220;p&#8221; for new paragraph.  Yet CSS recognizes these as if they were a normal selector.</p>
<p>The four pseudo elements are: before, after, first-letter, and first-line.  Before and after insert content before a block element and after a block element, respectfully, and are used with content that is generated dynamically, like with CMS systems.  First-letter is what you use to do drop-caps, and first-line will allow you to style the entire first line of a paragraph.</p>
<p>Let&#8217;s start with the html you&#8217;ll use.  You should use html as you normally do with paragraph tags around every paragraph, with one exception.  If you just want to style the first letter, or the first line, in the very first paragraph only, and not in every paragraph, you will have to identify that first paragraph with an id or class tag.  Other than that the pseudo element in CSS will take care of the rest.</p>
<p>First off, pseudo elements only work on block-level tags, like: p, blockquote, and h1, for example. And when you use them as a selector in CSS, the pseudo element has to be the last element in the selector chain, as shown here. </p>
<pre class="brush:html">
#car #carcolor p:first-letter {

}
</pre>
<p>Pseudo elements also only allow you to use properties that make sense to style the pseudo element.  With :first-letter you can use: font properties, text decoration, text transform, letter spacing, word spacing, line height, vertical-align (not when using floats), margin, padding, border, color and background.  Mostly anything to do with placing that first letter on your page.  The &#8220;first-line&#8221; uses the same elements with the exception of margin, padding, and border which are styled in the paragraph.</p>
<p>Rather than get bogged down in only use this or that, I recommend you just use them naturally, and you&#8217;ll find that they work the way you expect.  How do you use them?</p>
<p>In your CSS style sheet, if you would like to capitalize the first letter of every paragraph on the page, you would write:</p>
<pre class="brush:html">
p:first-letter {
font-size: 300%;
font-family:  garamond, bodoni, curly, times, serif;
color: orange;
padding-right: 1px;
position:relative;
margin-left: -26px;
}
</pre>
<p>Simple.  If you like to know what this looks like, take a look at the first letter of each paragraph in this article.  This is the CSS styling I used to style this page.
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2010/04/25/capitalize-the-first-letter-of-a-paragraph-with-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using PHP to Switch CSS styles on a Web Page</title>
		<link>http://www.geekgumbo.com/2010/03/16/using-php-to-switch-css-styles-on-a-web-pages/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-php-to-switch-css-styles-on-a-web-pages</link>
		<comments>http://www.geekgumbo.com/2010/03/16/using-php-to-switch-css-styles-on-a-web-pages/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 01:37:27 +0000</pubDate>
		<dc:creator>dale</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=946</guid>
		<description><![CDATA[CSS is a very powerful language to make the content of a web page look way you want it to look.  The new CSS3, when it&#8217;s ready, promises to add another dimension to styling web pages and make it easier to do styling that now takes a little more effort with JavaScript. One of the [...]]]></description>
			<content:encoded><![CDATA[<p>CSS is a very powerful language to make the content of a web page look way you want it to look.  The new CSS3, when it&#8217;s ready, promises to add another dimension to styling web pages and make it easier to do styling that now takes a little more effort with JavaScript.</p>
<p>One of the things that cause people problems, and is not built into CSS, is filtering CSS styles and applying one style if a certain condition exists.  In short, an &#8220;if&#8221; statement.</p>
<p>There are several workaround for this, one of which is to use PHP to switch styles depending on a condition.  Let&#8217;s take a look at the way you normally include a stylesheet in a web page.</p>
<pre class="brush:php">
<!--
<head>
<link rel="stylesheet" type="text/css" href="../css/cssfile.css" media="projection, screen" />

</head>
<body>
<h1>My Web Page</h1>

 And here is some content to style. 
<p class="reguser">Here some text to add if a register user logs into the site. 

</body>
 -->
</pre>
<p>The CSS file, cssfile.css, might look something like this:</p>
<pre class="brush:html">

h1 {color: blue;}
p {color: purple;}

.reguser {color: purple;}
</pre>
<p>Now suppose we only want the text in class &#8220;reguser&#8221;  to show up, with its special purple color styling,  if the user is registered on your site, and if the visitor is not registered, then the text will not be displayed.</p>
<p>Let&#8217;s use PHP to set up the condition.</p>
<pre class="brush:php">
<!--
<head>
<link rel="stylesheet" type="text/css" href="../css/cssfile.css" media="projection, screen" />

<?php

unset($user);
$user = $_SESSION['reguser']; 

if ( !isset ($user) ){
echo "link rel='stylesheet' type='text/css'  href='../css/addcss.css' media='projection, screen' ";
}

?>

</head>
<body>
<h1>My Web Page</h1>

And here is some content to style.
<p class="reguser">Here some text to add if a register user logs into the site. 

</body>

-->
</pre>
<p>In the PHP portion we unset a variable that we will use to track a registered user to initialize the variable.  We then set the $user variable to true if a user registered on another web page, using a $_SESSION variable.</p>
<p>We then get to the &#8220;IF&#8221; statement.  &#8220;IF&#8221; the $user variable is NOT set, as in the visitor did not register on the site, we add another CSS include file.  As an aside, you could have just as easily added another CSS file with an &#8220;elseif&#8221; statement.</p>
<p>Most web pages have many CSS files included, so adding another CSS file is nothing unusual.  It is encouraged.  In fact, CSS defines rules called specificity and the Cascade, as in Cascading Style Sheets, that determine which styling rules apply if there is more than one style assigned to the same element.</p>
<p>Let&#8217;s see what the second CSS file looks like to take out the registered user text on the web page.</p>
<pre class="brush:html">

.reguser {display: none;}
</pre>
<p>Well, that was easy.  The CSS says not to display the element, so it will disappear off the page, and the PHP lets you have conditionals in your web page styling.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2010/03/16/using-php-to-switch-css-styles-on-a-web-pages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Resizing the background image with CSS</title>
		<link>http://www.geekgumbo.com/2010/03/03/resizing-the-background-image-with-css/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=resizing-the-background-image-with-css</link>
		<comments>http://www.geekgumbo.com/2010/03/03/resizing-the-background-image-with-css/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 19:31:11 +0000</pubDate>
		<dc:creator>dale</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.geekgumbo.com/?p=895</guid>
		<description><![CDATA[With monitor resolutions getting larger and larger, and with the advent of large screen TV&#8217;s that can double as computer monitors, web developers have a dilemma. What resolution do you use to build a web site that will look good with all these different resolutions? It use to be that you built web sites for [...]]]></description>
			<content:encoded><![CDATA[<p>With monitor resolutions getting larger and larger, and with the advent of large screen TV&#8217;s that can double as computer monitors, web developers have a dilemma.  What resolution do you use to build a web site that will look good with all these different resolutions?</p>
<p>It use to be that you built web sites for a 800&#215;600 resolution monitor, those days are gone.  Now only about 3% of users have their monitors set at 800&#215;600.  The current sweet spot is 1024&#215;768 with 20% of the viewers using this resolution.  With more and more people moving to 1280&#215;800 at 19% and 1280&#215;1024 at 15%. The resolutions are all over the place.  At this point in time you should optimize your web site design for 1024&#215;768.  That means that those folks that are still using 800&#215;600 will have to scroll to see the screen.</p>
<p>The fact that a significant number of users not only have different resolutions, but most are greater than 1024&#215;768 has led web designers to design sites that stretch their width for different resolutions.  The CSS term for this type of layout is &#8220;liquid layout.&#8221;  The problem with liquid layouts is that if the screen stretches too wide, and text lines get longer and longer, text becomes difficult to read.  The solution for this is the &#8220;jello layout,&#8221; where the expansion of a web page is limited to a maximum width. </p>
<p>One of the solutions to the changing width is to use a consistent background color to surround your main content.  This works and it is the easy way out, the content is set to a maximum width and the background covers whatever width is left.  At higher resolutions though this looks ugly, too much background color.  The solution is to make your background more interesting with a background picture or composite image, and that&#8217;s when you run into some problems.</p>
<p>The traditional way to put a background image on your site is in the CSS file, like so: body {background-image: url(../images/myimage.jpg)}.  The only problem with doing that is that you can&#8217;t re-size the background image in CSS. To do this you have to move the image to your html file.  This allows you to style and re-size your image in the CSS file. </p>
<p>Before we get into how to do this, a word about the background image you will use.  If you expect to stretch the background image in width from one resolution to the next, you want an image that is more landscape oriented than portrait oriented.  The problem with a portrait image is if you stretch the image too much you will distort the picture, landscape images bend easier in width.  You also should scale the image to a size close to the size in width it will be at 1024&#215;768, or 1024px.  You can crop the image if it becomes too long in height. Lastly, you should worry about the image load time or the file size, and consider compressing the image to reduce the file size.</p>
<p>OK, we have the image we want for our background set up and ready to go.  How do we set the background image to re-size with changing resolutions.  First the html structure:</p>
<pre class="brush:php">

<body>
<!-- the background image -->
<div id="backimg">
  <img src="../images/myimage.jpg" alt="Background Image" />
</div>
<div id="bodywrap">
<div id="backdrop">

		<!-- your content -->
</div>
</div>

</body>
</pre>
<p>Nothing unusual here. We are inserting an image into the web page right after the body.  The tricks are in the CSS, let&#8217;s get to that&#8230;</p>
<pre class="brush:php">

* {
	margin: 0;
	padding: 0;
}

body {
	text-align: center;
}

#backimg img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	z-index: 0;
} 
</pre>
<p>That&#8217;s all there is to it&#8230;well, not quite. This will anchor your image to the upper left corner as a start point. The &#8220;position: absolute;&#8221; takes the image out of other relational groupings with the rest of your web page, and is important to making this work. The width: 100%; tells the browser to stretch the image across the entire monitor window.  Well, get to the z-index in a second.</p>
<p>Well, that&#8217;s all well and good, if you change browser resolutions, you&#8217;ll see the image stretch, depending on your monitor resolution, but how does the content area fit into this set up?  Well, the &#8220;bodywrap&#8221; tags represents the content of your web page. You want that centered in your window with the background image to show on either side of your content.  It would be nice if the content would re-size with the background, and well use the same technique to do just that.  Here&#8217;s the CSS.</p>
<pre class="brush:php">
#bodywrap {
	position:absolute;
	width: 94%;
	margin-left: 3%;
	margin-right: 3%;
	margin-top: 30px;
	z-index: 20;
}
</pre>
<p>This will expand your content with a 3% border for your image to show on the edges.  Use the margin-top: 30px; if you would like to show a piece of the background image at the top of the screen.  If you&#8217;d like to have your content have a white backdrop, we need to add another div.  It would be background image, then backdrop, then bodywrap for your content, here&#8217;s the CSS section for the backdrop, like so&#8230;</p>
<pre class="brush:php">
#backdrop {
	position: absolute;
	background-color: white;
}
</pre>
<p>Here the color of your backdrop is white and we have also taken the backdrop out of the web page components layout, but it is absolutely embedded in the bodywrap.  </p>
<p>Which brings us to the z-index.  The z-index tells the browser which layer to put on top of another layer.  The higher the number, the more that content block is moved to the front of the screen.  Thus our background image is 0 and the bodywrap is in front of that image at a z-index of 20.  </p>
<p>Here&#8217;s the complete CSS file in a compressed format. Enjoy.</p>
<pre class="brush:php">

* {margin: 0; padding: 0; }
body {text-align: center; }
#backimg img {position: absolute; top: 0; left: 0; width: 100%;	z-index: 0; }
#bodywrap {position:absolute; width: 94%; margin-left: 3%; margin-right: 3%; margin-top: 30px; z-index: 20; }
#backdrop {position: absolute; background-color: white; }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.geekgumbo.com/2010/03/03/resizing-the-background-image-with-css/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
