Categories
CSS

Images overflowing the boundaries of a DIV

A new month brought a new problem. I wanted to set up a staff page for a new site, with a box containing a photo and a profile of the person. The photo was floated to one side of the DIV or the other. I used alternating sides, but that's a matter of taste.

The problem was that if the text profile was too short, the image overflowed the bottom boundary of the div, which had a visible border around it.

Some digging around and experimenting revealed a solution.

The trick is to place <div style="clear:both"></div> just before the end of the DIV to clear the float.

Here's the code I wrote for this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
.silhouette {
  border: 1px solid silver;
  padding:1em;
  margin-bottom:.5em;
}
.silhouette img {
  border: 1px solid lightgrey;
  padding:2px;
  margin-bottom:.5em;
}
.imgleft {
  float:left;
  margin: 0px 10px 10px 0px;
}
.imgright {
  float:right;
  margin: 0px 0px 10px 10px;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<div class="silhouette">
<img src="" class="imgleft" /><p>Duis nec elementum magna. Vivamus malesuada blandit mauris, nec consectetur leo accumsan at. Donec risus enim, porttitor non tristique eu, viverra eu orci. Ut id orci ac elit placerat volutpat. Proin eu nisi ac odio aliquet egestas. Ut vitae justo sed nisi adipiscing suscipit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante.</p>
<div style="clear:both"></div></div>
 
<div class="silhouette">
<img src="" class="imgright" /><p>Proin eu nisi ac odio aliquet egestas. Ut vitae justo sed nisi adipiscing suscipit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante. Duis nec elementum magna. Vivamus malesuada blandit mauris, nec consectetur leo accumsan at. Donec risus enim, porttitor non tristique eu, viverra eu orci. Ut id orci ac elit placerat volutpat. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante. Duis nec elementum magna. Vivamus malesuada blandit mauris, nec consectetur leo accumsan at.  Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante. Duis nec elementum magna. Donec risus enim, porttitor non tristique eu, viverra eu orci.  Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante. Duis nec elementum magna. Ut vitae justo sed nisi adipiscing suscipit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante. </p>
<div style="clear:both"></div></div>
 
<div class="silhouette">
<img src="" class="imgleft" /><p>Vivamus malesuada blandit mauris, nec consectetur leo accumsan at. Duis nec elementum magna. Donec risus enim, porttitor non tristique eu, viverra eu orci. Ut id orci ac elit placerat volutpat. Proin eu nisi ac odio aliquet egestas. Ut vitae justo sed nisi adipiscing suscipit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante.</p>
<div style="clear:both"></div></div>
 
<div class="silhouette">
<img src="" class="imgright" /><p>Ut id orci ac elit placerat volutpat. Proin eu nisi ac odio aliquet egestas. Ut vitae justo sed nisi adipiscing suscipit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante.</p>
<div style="clear:both"></div></div>

And the final result:

Note that the image files are not actually shown.

Duis nec elementum magna. Vivamus malesuada blandit mauris, nec consectetur leo accumsan at. Donec risus enim, porttitor non tristique eu, viverra eu orci. Ut id orci ac elit placerat volutpat. Proin eu nisi ac odio aliquet egestas. Ut vitae justo sed nisi adipiscing suscipit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante.

[ad]

Proin eu nisi ac odio aliquet egestas. Ut vitae justo sed nisi adipiscing suscipit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante. Duis nec elementum magna. Vivamus malesuada blandit mauris, nec consectetur leo accumsan at. Donec risus enim, porttitor non tristique eu, viverra eu orci. Ut id orci ac elit placerat volutpat. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante. Duis nec elementum magna. Vivamus malesuada blandit mauris, nec consectetur leo accumsan at. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante. Duis nec elementum magna. Donec risus enim, porttitor non tristique eu, viverra eu orci. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante. Duis nec elementum magna. Ut vitae justo sed nisi adipiscing suscipit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante.

Vivamus malesuada blandit mauris, nec consectetur leo accumsan at. Duis nec elementum magna. Donec risus enim, porttitor non tristique eu, viverra eu orci. Ut id orci ac elit placerat volutpat. Proin eu nisi ac odio aliquet egestas. Ut vitae justo sed nisi adipiscing suscipit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas augue odio, rutrum bibendum convallis eu, gravida non ante.

Ut id orci ac elit placerat volutpat. Proin eu nisi ac odio aliquet egestas. Ut vitae justo sed nisi adipiscing suscipit.

Categories
Uncategorized

Use Synergy instead of a KVM Switch

If you've ever wanted a KVM switch, forget about it.  Synergy, an open source tool, replaces a KVM with a free software solution.

A software-only solution, it communicates across the network instead of through dedicated cables, so you can reduce your cable clutter.

Simply tell the configuration where the computers are located relative to each other (i.e. "laptop is to the left of desktop and desktop is to the right of laptop.)

As soon as the mouse passes the edge of the screen, it goes to the other computer mouse and keyboard now act on that machine.  As I write this post my laptop's external monitor is to the left of my desktop, and my server monitor is to the right of my desktop monitor.  One sweep of my hand and my mouse passes across all three monitors.

You can even cut and paste across computers.  That feature is a little buggy, but that's the worst thing I can think of to say about this little gem.

If you're using Vista, be sure to set AutoStart to "When You Log In" instead of "When Computer Starts".  You may also need to disable UAC.  I haven't tried it on Windows 7 yet, but I'm going to guess that the same would hold true.

This would be worth real money, but as open source, it's free, so just enjoy it.

You can download Synergy for free here.

Categories
Web Development

Getting a website online – for neophytes

You want a website, but haven't a clue how to go about it.  That's OK, everyone who knows how to do it once had to do it for the first time.

Here's a quick guide to getting a website up for very little money, very little work and very quickly.  My solution involves using the free and popular WordPress blogging platform to host your site, and this is a great way to get your first website up and running quickly.

Registering a Domain Name

First, you need to pick a registrar.  That's the company that actually hooks you up with the great registrar of domain names at the heart of the Internet.  Don't worry about the technical details, you really don't need to know unless you want to.  Personally, I don't register my domains where I host my websites.  Too many people lose their domain names in a dispute with a web host when it turns out the web hosting company has control or even technically owns the domain, much to the dismay of the unsuspecting customer.

I use www.easydns.com in to register domains.  It's $20-25/year to register the domain and I've always had good service from them.  If you want to let me have a new affiliate points for pointing you to them use this link to EasyDNS it's your call, I won't beg.

To pick your domain name, go to www.easywhois.com and try out a few names to see if the domain you want is available.  I use that site because they commit to not frontrunning, which is a dirty little trick where a site will offer to do the lookup for you, then slap a 5 day hold on the domain and tell you it's taken, but they can sell it to you – at a price.

When you register your domain name, you'll be asked for the Registrant – that's the legal owner – probably you, as well as Admin, Technical and Billing contacts.  Probably all those people will be you but be sure to keep the info and password in a safe place.  And set a tickler to renew the domain annually.  If you change your email and the reminders don't get to you, you'll lose the domain, which is bad.

Incidentally, you can get a domain registration a little cheaper, but I'm happy to pay an extra $6-7 per year for a registrar who has a good reputation and to avoid registering my domain names where I host my sites.

Setting up your Website

WordPress.com offers two attractive options to host your blog.  If you want to use WordPress to host your site it's free.  But you can also pay them USD$10/year to attach your domain name to their WordPress servers so your domain name is what people go to, not www.wordpress.com.

Either way, you pick one of their WordPress templates.  The template controls the visual appearance of your website.

The downside of using wordpress.com to host your site is that you have to pick one of their templates and there's only minimal customizing possible.  The upside is that they to all the updates automatically – you don't need to worry about maintenance – and it's dirt cheap.

WordPress deals with static content in pages and more chronological content like blogging in posts.  For a resume website you'd want to forget about posts and put up static pages with your resume and contact information.

You can go to WordPress at any time and try them out free.  Join for free and set up http://yourname.wordpress.com.  Experiment with the templates and pick one you like.  There's lots of very good how-to info at http://codex.wordpress.org.  They don't charge for their basic blogging service, but paying the $10 lets you attach your domain name to it, which is a really good idea.

Down the Road

At some point in the future, you can get a hosting plan (roughly $100-$120/year) and use an open source content management system like Joomla to create a more complicated website, but if it's just a resume you'll likely find WordPress all you need and you can't beat the price.

Categories
Graphics

Fading out the edge of a photo in Fireworks

This is a great technique to use when creating banners and header graphics;

http://www.learnwebdesignonline.com/introfireworks/gradient-masking.htm

Categories
Uncategorized

Using an associative array to replace text in PHP

Imagine you have to write out some attribute names from your database, but want to replace them with more user-friendly versions. For instance, "First Name: " rather than "fname".

An assocative array in PHP will do the trick nicely.

For instance:

1
2
3
// labels array will be used to replace the database attribute names with field labels
$labels = array("lname"=>"Last Name","fname"=>"First Name");
echo "This line displays the ".$labels["lname"];

returns

This line displays the Last Name