CSS Position Property

November 14th, 2007, 10:56 pm

Some people have a hard time figuring out the position property in CSS. It took me a while to fully understand it and use it to it’s full potential. Here is some information on it and hopefully you can understand it.

position: relative; positions the element relative to it’s nromal position. An elements normal position is its position in the flow of the page. So top: 5px and left: 30px; will move it down 5 pixels and left 30 pixels from it’s normal position on the page.

position: absolute; moves it to a certain spot within the first parent element that has been positioned before it. This is where it gets tricky. This defaults to the browser window if you haven’t positioned any parent elements. Examples will make this easier for me to explain.

<h1>Positioning Example</h1>
<div style="width: 500px; height: 500px; border: 1px #000000 solid;">parent element
<div style="position: absolute; bottom: 0px; left: 0px">child element</div>
</div>

View Example

In this example, child element will be in the bottom left corner of the browser window although the parent element doesn’t go below 500 pixels or the window is shorter than 500 pixels. The child element will be in the bottom left corner of the browser window even if you can scroll below the page.

<h1>Positioning Example</h1>
<div style="width: 500px; height: 500px; border: 1px #000000 solid; position: relative;">parent element
<div style="position: absolute; bottom: 0px; left: 0px">child element</div>
</div>

View Example

In this example, child element will be in the bottom left corner of the parent element. This is because parent element has now been positioned so it becomes the containing block and position: absolute will move elements around within that block.

Godaddy and mod_rewrite

August 21st, 2007, 04:31 pm

If you are considering using Godaddy to host your website, don’t. Run away as fast as you can and get a proper web host. The more I have used Godaddy for more only domains, the more I hate them. Godaddy is a domain company and nothing more. Yes, they are cheap and that is service you get. Cheap.

Today I found out that Godaddy doesn’t mod_rewrite files ending in .php. You can redirect other file types to php files but you can’t rewrite php files to other files.

I’m guessing this is because Godaddy parses php files before it even gets to your .htaccess file.

Godaddy, can you server setup be any more messed up? Why can’t you do it properly?

Updated Changing Avatar Script

August 13th, 2007, 11:22 am

I’ve updated my script that I previously blogged about that changes your avatar on different sites depending on what month it is.

Put the following to your website. In my example I’m naming it avatar.php

Add cases for the months you want to add or change. Change $avatar to the correct image. Change $type so that it is appropriate for the correct image. Gifs are image/gif. Jpgs are image/jpeg.

<?php

$month = strtolower(date('M'));

$avatar = '';
$type = '';
switch($month)
{
	case 'oct':
		$avatar = 'pumpkin.gif';
		$type = 'image/gif';
		break;

	case 'dec':
		$avatar = 'christmas-tree.gif';
		$type = 'image/gif';
		break;

	default:
		$avatar = 'elephant.gif';
		$type = 'image/gif';
		break;
}

header('Content-type: ' . $type);
readfile($avatar);

exit;

?>

In a .htaccess file add the following

RewriteRule avatar.jpg avatar.php
RewriteRule avatar.gif avatar.php

To use your dynamic avatar, you can link to either avatar.jpg or avatar.gif on your website. Preferably keep all of the image types the same.

If you have any questions, bugs or anything, let me know.

Are you a web programmer looking for a full time job?

February 21st, 2007, 01:22 pm

The studio I work for could use another programmer so ff you are a web programmer in the Salt Lake area looking for a full time job, contact me and I’ll get you some more information. Need to know XHTML, CSS, Javascript, PHP, and SQL. Pretty much the basics to web programming. Preferably you should be out of school.

Could possibly be part time. Can still be in school if part time.

My email is eric (< [at]>) ericfaerber (< [dot]>) com. Remove (< [ and ]>). Thanks.

Job Hunting

March 30th, 2006, 08:28 pm

I’m looking for a job. I’d like to work for company that does web development but that might not happen. I’ve applied to a few of places so hopefully one of those will work out. If you have any leads on a job, let me know ;)