Archive

Archive for the ‘Design’ Category

Get that footer to stay at the bottom

August 27th, 2009 No comments
and STAY down from LOLcats

and STAY down from LOLcats

Every web designer has tackled the problem of keeping that footer at the bottom of the page, no matter the amount of content above it. At first look one might assume this is a simple task, but as it turns out, you can really drive yourself batty trying to make this seemingly simple task to happen.

A while back I settled on a not so perfect solution that used min-height’s to get the job done. This was alright, but it was problematic in that you never know how your user will have his or her browser sized. I continued on with the development of the site, but never felt quite right about leaving the footer that way. Today I decided to look for a better option once again, and I sure am glad I did! I happened upon Ryan Fait’s Make the Footer Stick to the Bottom of the Page solution!

The solution is so simply beautiful that it makes me wonder how it took so gosh darn long to figure out! There is really only one extra div in the html, and only 15 lines of css! Wait a second, did I just say “gosh darn”? Right well, never mind that.  Head over Ryan Fait’s site for all sorts of design resources, including the Sticky Css Footer I love so much!

The Future of Round Corners

April 29th, 2009 2 comments

I seem to been obsessed with round corners, with all of the posts I have written on the topic (I had no idea!), so I thought I’d do some research into the future of round corners on these great inter-tubes and share my findings with you.

Currently the Mozilla based web browsers, Firefox being the most popular, supports the css directive -moz-border-radius, which effectively gives web elements round corners without using and nested divs or images. It really works quite beautifully, but it only exists in the Mozilla based browsers. IE, and others don’t know what to do with the directive, and just toss it out.

I’m a rounded div!

The Mozilla border-radius directive can be broken down to specify each corner to have it’s own roundness:

.funnyRoundDiv{
     -moz-border-radius-bottomleft: 0px;
     -moz-border-radius-bottomright:5px;
     -moz-border-radius-topleft:10px;
     -moz-border-radius-topright:20px;
}
I’m a funny rounded div!

The CSS3 web standard has specified that browsers that meet the standards will implement this same functionality with the CSS3 directive border-radius. CSS3 is still a work in progress, and it will be an even longer wait for all of the browsers to catch up with the standards it sets. Us web developers do have some good things to look forward to though!

If you are interested in learning more about CSS3, Six Revisions has an awesome LIST of Useful Resources for CSS3.

Gotta love lists!

Categories: Design, Web Development Tags: ,

Images with Round Corners

April 21st, 2009 No comments

The effect of giving an images round corners is becoming increasingly popular lately, as the human eye really likes soft curves. The recent redesign of Facebook utilizes images with round corners very well, despite the backlash to the constant UI changes at the popular social network.

To give List Central a better aesthetic, I decided to also utilize round corners on the avatars to be displayed all over the site. Ia quite like the effect of mixing roundness with straight lines in a design. The effort put into implementing the small images with round corners was well worth it, and now, I can share my knowledge of how to do it with you:

Creating an image with round rectangles in your favourite image editor is fairly easy by using a round rectangle as a mask, but that solution lacks flexibility, and doesn’t suit List Central’s purposes at all! I can’t be sitting around setting up each and every List Central avatar with pretty round corners in Photoshop! In order to achieve the aesthetic effect, a combination of html an css has to be used.

.
Avatar Image.
.

.
Round Corners Image.
.

.
.
.
.
The Two Put Together
.
.

.
.
.
.
.
.
.

.
On White
.
.

.

.
.
.

<style>
.RoundAvatarWrapper{
     /* Avatar positioning CSS goes here */
}
.AvatarImage {
     position:absolute;
     width:100px;
     height:100px;
     z-index:0;
}
.RoundCorners{
     position:absolute;
     width:100px;
     height:100px;
     z-index:1;
}
</style>
<div class=’RoundAvatarWrapper’>
     <img class=’AvatarImage’ src=’/images/avatar.jpg’
          width=’100′ height=’100′ />
     <img src=’/images/round_corners.png’
          class=’RoundCorners’/>
</div>

As you can see above, the avatar image that is used is completely intact. The round corner effect is achieved by layering another image on top of the avatar that has a transparent middle, and round corners of the same colour as the background. I opted for an round outline in my overlay image, which is completely optional.

The CSS classes “RoundCorners” and “RoundAvatarWrapper” is where the magic happens. Most importantly, the sizing and absolute positioning of the wrapping divs force the round corners image and the avatar image to appear in the same space. Then, specifying the z-index for each allows you to force the round corners image, with the transparent middle, to appear above the avatar image, give the appearance of an image with round corners.

Share Buttons are SO Easy!!

April 14th, 2009 No comments

The viral aspects of the social web are all the rage these days. If you want traffic, the best and cheapest method to get it is to harness social media sites like Digg, Reddit, StumbleUpon, Twitter, Delicious and Facebook.  Social medial sharing is the new, high tech version of word of mouth.

It was a no brainer for me to include share buttons on List Central, to make it easy for my users to spread the word about cool lists that they find. Fortunately, the developers at the big social networking sites have made it easy to add share buttons on your site. It took me less than a couple hours to set up share buttons for my 5 favourite social media site on List Central. The following is a breif summary of how to get going with share buttons for each of the sites I implemented:

Digg offers a page full of documentation to help you implement links to digg your stories on their Digg Integrate page. There are two facets to sharing stories on Digg: digging, and submitting a story that hasn’t previously been submitted. The good people at Digg have put together an easy to install script that figures out whether or not the story has been submitted previously, and takes the user who clicks on the icon to the appropriate place.

<script type=’text/javascript’>
digg_url = ‘http://blog.listcentral.me/2009/04/06/share-buttons-are-so-easyshare-buttons-are-so-easy/’; digg_skin = ‘icon’;
digg_window = ‘new’;
</script> <script src=’http://digg.com/tools/diggthis.js’ type=’text/javascript’></script>

As the code above illustrates, Digg gives you the option to specify the url you want to be dugg, as well as the target of the link, and the digg skin for the share button. The skins available are ‘normal’, which looks like the Digg buttons on Digg itself that displays how many diggs the story has already, ‘compact’, which is a smaller version of the normal skin, and lastly, the one I like best, ‘icon’, which is displayed above.

Facebook offers brief, yet comprehensive documentation on how to create share buttons on the Facebook Share Partners page. The Facebook team has made the task of creating Facebook share buttons super easy with the script they provide, in that the developer only needs to add in the url of the page to be shared. Facebook also offers 4 options for how the share link can appear on your site, my favourite is the small icon shown above.

<script>function fbs_click() {
u=location.href;
t=document.title;
window.open(‘http://www.facebook.com/sharer.php?u=’+encodeURIComponent(u)+’&t=’+encodeURIComponent(t),’sharer’,'toolbar=0,status=0,width=626,height=436′);
return false;}
</script><a href=’http://www.facebook.com/share.php?’ onclick=’return fbs_click()’ target=’_blank’><img src=’http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981′ width=’16′ height=’16′ alt=” /></a>

StumbleUpon has a neat page with many options to help you build your share buttons on the StumbleUpon Buttons & Tools page. Once you build one link through the StumbleUpon builder, it is easy to see how to edit the code in order to make other share buttons for different links automatically. All that is needed is the link’s url and title.

<a href=’http://www.stumbleupon.com/submit?url=http://blog.listcentral.me/2009/04/06/share-buttons-are-so-easy&title=Share Buttons are SO Easy!!’ target=’_new’> <img border=0 src=’http://cdn.stumble-upon.com/images/32x32_su_round.gif’ width=’16′ height=’16′ alt=”></a>

Delicious also makes creating share buttons super easy with the scripts they have posted on the Delicious Save Buttons page. The code they provide requires no edits, as it works perfectly as it is. I did edit the code they provide for aesthetic reasons. I wanted to use only the Delicious icon as my share button, rather than the text “Bookmark this on Delicious” that the code Delicious provides includes, a fairly trivial change really.

<a onclick=’window.open(‘http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url=’+encodeURIComponent(location.href)+’&amp;title=’+encodeURIComponent(document.title), ‘delicious’,'toolbar=no,width=550,height=550′); return false;’ href=’http://delicious.com/save’><img src=’http://static.delicious.com/img/delicious.small.gif’ alt=’Delicious’ width=’10′ height=’10′ /> </a>
Tweet this list

Twitter is the exception, in that they do not provide documentation on how to create share buttons on your site, but their simple design makes it reasonably easy to figure out how to do it.

<a href=’http://twitter.com/home?status=Check this out! http://blog.listcentral.me/2009/04/06/>Tweet This’</a>

If the user is already logged into Twitter, when they click on a link w they will be taken to their twitter home page, with the Tweet pre-populated with the text you give it after the ‘status=’ in the link. As a developer, you can choose to use anything as the link text or image. For List Central, I chose the Twitter ‘t’ icon, which the good folks at twitter use as their favicon.

Centering an image in a div

April 6th, 2009 2 comments

While I’m trying to build List Central, I have also, slowly, been designing another blog called Urpi’s Dream. I have a long term vision for Urpi’s Dream, and while I know that I won’t be able to devote too much time to it during the reign of List Central, on occasion I get completely obsessed with certain aspects of this other project.

One of these obsessions was to build a new WordPress plugin to hold the specific functionality I want in a image gallery. Yes, I built, yet another, WordPress Image Gallery Plugin. I know there are many others out there that do the job, but none that did it to my satisfaction, so I built my own. I still have a few more touch ups to do on Urpi Gallery, but once those are completed, I’ll be releasing the plugin to the WordPress community. I’ll likely make an announcement about it here as well as on Urpi’s Dream.

All of that chatter has little to do with the point of this post. The point of this post is to discuss how to dynamically center and image in a div! So let’s get to the meat of it!

A part of the Urpi Gallery, mentioned above, is a rotating image widget that can either be used on the sidebar, or in posts. Here’s an example of it, with some purdy pictures of flowers I found on Flickr under the Creative Commons license :



As you can see above, the dynamically chosen image is very nicely centered in that gray div. I thought that centering an image in a div, as above, would be a piece of cake, but it turned out not to be so clear cut.

Centering an image in a table cell, both horizontally and vertically is trivial:

Benny &lt;style&gt;
.centeredImageTD {
width: 180px;
height: 180px;
vertical-align:middle;
text-align:center
}
&lt;/style&gt;

<td class=”centeredImageTD”>
<img src=”Benny.jpg” width=”120″ alt=”Benny” />
</td>

Isn’t that easy? All done with some css on the table cell (td) that explicitly states: center the content of this table cell, both horizontally and vertically. The dimensions of the image don’t matter with this method of centering.

As the web has evolved, the appropriateness of tables in web design has decreased, and the task now is to put our designs together using divs. The use of divs improves many web design tasks, but it makes this one task, of centering images more difficult. While the tag can be used in a pinch to center an image horizontally, there is no equivalent tag or style rule to center an image vertically. The only option is to use the margins of the image, or the padding on the div. Both require that you know the width and height of the image, and div.

As I was determined to have my images centered in a div, I got down to writing  my  php functions to make it happen, every time. The function below requires that you pass the actual dimension of the image, which can be captured with tools like identify from ImageMagick, or with the built in php functions imagesx and imagesy. Also required by the function is the  desired width of the border given to the image ($border_width), and the width of the div you want to center your image in as $divsize.  This function assumes your div is square, but it is possible to adapt this function to accommodate rectangular divs.

/*
getCenteredMargins - determines the margins for an the image to be centered in a div

1. $imagefile – Path to the image
2. $divsize – The width and height of the square div containing the image in pixels
3. $border_width – The width of the desired boreder around the image in pixels
4. $max_size – The maximum width and height of the image as it is to appear on the page
*/
function getCenteredMargins($image_width, $image_height, $divsize, $border_width, $max_size){

    // Initializations
    $width = 0; $height = 0;
    $margin_top_bottom = “”; $margin_left_right = “”;

    if($image_width > $image_height){
        // Most likely a pic landscape orientation, width of         the image will
        // equal the max_size
        $width = $max_size;

        // Determine scaled down height of the image with the the ratio
        // of the original image
        $height = (int)($max_size * $image_height / $image_width);

        // right and left margins will be small, and equal to the
        // specified border width
        $margin_left_right = $border_width . “px”;

        // top and bottom margins will be larger
        $margin_top_bottom = (int)(($divsize – $height) / 2) . “px”;
    }else{
        // Most likely a pic portrait orientation, height of the image will
        // equal the max_size
        $height = $max_size;

        // Determine scaled down width of the image with the the ratio
        // of the original image
        $width = (int)($max_size * $image_width / $image_height);

        // top and bottom margins will be small, and equal to the
        // specified border width
        $margin_top_bottom = $border_width . “px”;

        // right and left margins will be larger
        $margin_left_right = (int)(($divsize – $width) / 2) . “px”;
    }
    return array($margin_top_bottom, $margin_left_right,$width, $height);
}
list($margin_top_bottom , $margin_left_right, $width, $height) = getCenteredMargins($image_width, $image_height, $divsize, $border_width, $max_size);
$image_style = “margin: $margin_top_bottom $margin_left_right;”;
$html = “<div><img  style=”$image_style” src=”$src” width=”$width” height=”$height” /></div>”;