View Full Version : How To: Custom Banner with Built-In Links
Jonathan R. Walcher
Feb-15-2007, 01:54 PM
A couple of people were interested in how I created my banner with built-in links so here is a brief, first attempt at an How-To article.....
Background
The idea for this came, in part, from the many examples of websites shown on www.live-books.com (http://www.live-books.com), an excellent company that creates custom portfolio-centric websites. I wasn’t satisfied with the Banner/Navbar combination that I was using; I wanted something more compact and minimal so I began the search on how to create an image sliced banner that would allow me to combine the links and my banner into a single item on my page. In the past, I would have just opened Adobe ImageReady and gone to work on slicing the image up as I pleased and putting in the necessary link information. This time though, I didn’t want to mess with the numerous images that manual slicing creates and I wasn’t confident that the table code that ImageReady produced would work in the SmugMug setting. After a bit of searching I found this (http://alistapart.com/articles/sprites/) article by Dave Shea that in turn provided the code below….many thanks to him for writing such a great article.
The Code
I’m not going to provide detailed explanations as to what each item does; Dave’s article does a thorough job of that.
Things to have before you start copying and pasting:
The URL to your banner image.
The width and height of the entire image in px.
The relative locations of the links within the image measured in px starting from the left of the image. Note: while I didn’t use the HTML code or images that ImageReady created, the slicing function allowed me to get the exact location for each “panel” or link within my banner. If you have a tool that will allow you to do this I highly suggest you use it. It’s not necessary though; with a bit of patience and the borders of the panels turned on (example below) you could probably guess your way through this part. /* Beginning of CSS section copy & paste -- copy white text only */
#BannerImg {
width: (width-of-entire-image-here-remove-parenthesis)px; height: (heighth-of-entire-image-here-remove-parenthesis)px;
background: url(link-to-your-image-goes-here);
margin: 0px auto; padding: 0;
position: relative;}
#BannerImg li {
margin: 0; padding: 0; list-style: none;
position: absolute; top: 0;}
#BannerImg li, #BannerImg a {
height: (heigth-of-entire-image-here-remove-parenthesis)px; display: block;}
#BannerImg a {border: solid 1px #f00;}
/* To remove the borders around the panels remove the last line above*/
/* Each panel represents a block. These measurements are provided by example only. They are specific to my banner and will need to be modified to match the “link” locations your banner. */
#panel1b {left: 0; width: 501px;}
#panel2b {left: 501px; width: 58px;}
#panel3b {left: 559px; width: 49px;}
#panel4b {left: 608px; width: 41px;}
#panel5b {left: 649px; width: 66px;}
#panel6b {left: 715px; width: 52px;}
/* End of CSS section C&P */
/* Beginning of Header Section C&P – Replace with your links of course*/
<ul id="BannerImg">
<li id="panel1b"><a href="Your-HomePage-Link"></a></li>
<li id="panel2b"><a href="Gallery 1 Link"></a></li>
<li id="panel3b"><a href="Gallery 2 Link"></a></li>
<li id="panel4b"><a href="Gallery 3 Link"></a></li>
<li id="panel5b"><a href="Guestbook link"></a></li>
<li id="panel6b"><a href="javascript:norobotmail('yourEmailName', 'yourDomain')"></a></li>
</ul>
/* End of Header Section C&P */
NOTE: The link in panel6b above is one of a two part spam-proof way to give out your E-Mail Address. Details can be found on this (http://www.dgrin.com/showthread.php?t=18036&highlight=%27yourDomain%27%29%22) thread (and many others).
Here is an example of how my banner looks with the borders turned on. If you don’t have a way to measure out the pixels of each link I’m sure you could guesstimate by changing the dimensions of the panels.
http://www.jonathanwphotography.com/photos/129866340-M.jpg
This post is nothing more than an abbreviated version of the article about CSS sprites referenced above. I highly recommend you at least browse through it so you get and idea of how everything works. In addition, the article provides ways to tackle things like hovers and buttons using css alone, something I haven’t attempted yet because of time. Another thing I think is possible but I’ve not attempted is having specific locations of panels rather than proportional blocks. If I find a way to accomplish that I’ll post it.
If you try it let me know, I would love to see your work!
Cheers :D
Mike Lane
Feb-15-2007, 02:15 PM
I've been using sprites for quite some time now. I used it for the navbar http://www.pristine-light.com/ (which I used as the basis for the spoonman theme) and for various iterations on my site (my navbar currently) and for various theme elements in current and upcoming themes.
Just as a note, you may be better served by not using one huge image but rather smaller repeated backgrounds where applicable and positioned elements where possible. It will make your header code much smaller and faster loading.
S&SPhoto
Feb-20-2007, 05:00 PM
Jonathan, Mike,
Many thanks for posting this. I tried this out and it works like a charm!
Samir
Jonathan R. Walcher
Feb-20-2007, 05:10 PM
Jonathan, Mike,
Many thanks for posting this. I tried this out and it works like a charm!
Samir
Great Job Samir! You even got the hovers to work...way to go man!:thumb
JRW
Frenchy
Feb-23-2007, 08:59 AM
Hi this is my first time asking for help here I have been doing alright ( i think so far) The problem is 1. I can't get the hover to work 2. my first link is not lining up 3. I am trying not to use the entire banner as clickable but only where the buttons are,
Thanks,
Matt
www.MoJoPhotography.smugmug.com (http://www.MoJoPhotography.smugmug.com)
I haven't taken the old navbar out yet, thought I wait until I get this one working
S&SPhoto
Feb-23-2007, 10:51 AM
Hi this is my first time asking for help here I have been doing alright ( i think so far) The problem is 1. I can't get the hover to work 2. my first link is not lining up 3. I am trying not to use the entire banner as clickable but only where the buttons are,
Thanks,
Matt
www.MoJoPhotography.smugmug.com (http://www.MoJoPhotography.smugmug.com)
I haven't taken the old navbar out yet, thought I wait until I get this one workingMatt,
Thanks for posting. I followed the tutorial in the first post that Jonathan provided. If you look at the sample image they use, it is actually ONE jpg file. The top half is the image you want to display without showing any hover effects. The bottom image is what you want displayed when someone mouses over.
I took a look at your CSS and it appears that you are using two separate images. While it may be possible to do this, I don't know how.
Here is the image (http://ssp.smugmug.com/photos/130026078-O.jpg) I used on my site. The top one third is what is displayed with no hover. The middle is what you see when you hover over a link. The bottom is what you see when you are clicking on a link (credit to Mike Lane -- see his post in this thread!).
Try that and see what you come up with.
Thanks.
Samir
Frenchy
Feb-23-2007, 02:57 PM
ok i am giving it a shot, would you know how to isolate the click ability to just the buttons?
Frenchy
Feb-23-2007, 03:28 PM
How do you make the panels smaller
S&SPhoto
Feb-23-2007, 05:13 PM
ok i am giving it a shot, would you know how to isolate the click ability to just the buttons?I think you may need to break things up. Create one jpg with just your banner. Create another image, similar to the example in the tutorial Jonathan linked to in post #1. The second image is what will contain your links. See Mike Lane's site http://www.pristine-light.com/ for an example of what you are trying to do.
How do you make the panels smallerI'm not quite sure what you're referring to, but I created my image in GIMP. I would imagine you can do the same thing in Photoshop.
Samir
Frenchy
Feb-24-2007, 06:31 AM
OHHHHH I think I get it!!! I will give it a shot
Jonathan R. Walcher
Feb-24-2007, 07:19 PM
OHHHHH I think I get it!!! I will give it a shot
Frenchy....it looks like you've accomplished what you set out to do.:thumb
Thank you Samir for helping!....If I get a chance in the near future I'll update the how-to with instructions on how to do the hovers...i've got to make use of them first :huh
Frenchy
Feb-25-2007, 10:12 AM
thanks guys
scwalter
Mar-07-2007, 09:53 PM
Jonathan, Mike,
Thanks guys, got it working on my site too.
-Scott
gwyneth
Mar-09-2007, 02:51 PM
So, I'd like to do this w/ a drop-down...is that possible? And, to FURTHER complicate that, I would like the drop downs to be images (to ensure that "my" font is displayed. Is this possible?
Mike Lane
Mar-09-2007, 03:02 PM
So, I'd like to do this w/ a drop-down...is that possible? And, to FURTHER complicate that, I would like the drop downs to be images (to ensure that "my" font is displayed. Is this possible?No sorry you can't do it.
:D
Yes of course you can do that but if anyone tells you it's going to be easy they're lying. Start with a dropdown navbar. Then make the text disappear one of several different ways and then use an image background for the link elements, then simply change the background position for the hover state, and then simply change the background position again for the active state. If you don't want your font to change just make that a part of the image you use. That'll mean you have to update your navbar in photoshop each time you add or remove a link, but hey, if it's worth it to you to do that, you go girl!
I'm deliberately not going to go into how to do this. Though it isn't all that complicated to be honest I'm too busy in other areas to really follow through with it.
I'm sure someone else will pick up on it though.
gwyneth
Mar-09-2007, 03:54 PM
thanks Mike.
Anyone? step by step?
Jared
Mar-17-2007, 06:56 AM
I cant figure this out :scratch
I just made hover images on my banner with css based on Samir's...but now its not showing any part of the image unless I hover on it and its not positioned correctly any more either.
Can someone take a look and see if you can spot my problem? the image Im using is located here (http://sharpshooter.smugmug.com/photos/136571604-L.jpg) and this is my code:
/* CSS Document */
/* clickable banner */
#BannerImg {
width: 750px;
height: 100px;
background: url(http://sharpshooter.smugmug.com/photos/136571604-L.jpg);
margin: 0px auto;
padding: 0;
position: relative;
padding-bottom: 0px;}
#BannerImg li {
margin: 0;
padding: 0;
list-style: none;
position: absolute;
top: 0;}
#BannerImg li, #BannerImg a {
height: 100px;
display: block;}
#panel1b {left: 0; width: 279px;}
#panel2b {left: 279px; width: 86px;}
#panel3b {left: 365px; width: 73px;}
#panel4b {left: 438px; width: 83px;}
#panel5b {left: 521px; width: 61px;}
#panel6b {left: 582px; width: 98px;}
/* Apply hover image to links */
#panel1b a:hover {
background: transparent url(http://sharpshooter.smugmug.com/photos/136571604-L.jpg)
0 -100px no-repeat;
}
#panel2b a:hover {
background: transparent url(http://sharpshooter.smugmug.com/photos/136571604-L.jpg)
-279px -100px no-repeat;
}
#panel3b a:hover {
background: transparent url(http://sharpshooter.smugmug.com/photos/136571604-L.jpg)
-365px -100px no-repeat;
}
#panel4b a:hover {
background: transparent url(http://sharpshooter.smugmug.com/photos/136571604-L.jpg)
-438px -100px no-repeat;
}
#panel5b a:hover {
background: transparent url(http://sharpshooter.smugmug.com/photos/136571604-L.jpg)
-521px -100px no-repeat;
}
#panel6b a:hover {
background: transparent url(http://sharpshooter.smugmug.com/photos/136571604-L.jpg)
-582px -100px no-repeat;
}
/* end clickable banner */ <ul id="BannerImg">
<li id="panel1b"><a href="http://sharpshooter.smugmug.com" title="Front"></a></li>
<li id="panel2b"><a href="http://sharpshooter.smugmug.com/Portfolio" title="Jared's Portfolio"></a></li>
<li id="panel3b"><a href="http://sharpshooter.smugmug.com/gallery/2584160" title="About Jared"></a></li>
<li id="panel4b"><a href="http://sharpshooter.smugmug.com/gallery/2584163" title="Contact Jared"></a></li>
<li id="panel5b"><a href="http://sharpshooter.smugmug.com/gallery/2582373" title="Updates"></a></li>
<li id="panel6b"><a href="http://sharpshooter.smugmug.com/gallery/2584166" title="Sign Here"></a></li>
</ul>
What confuses me more is that it works fine when I preview it out of Dreamweaver...
Jared
Mar-17-2007, 08:48 AM
Well nevermind...I didnt figure out what the problem was, but it is working now :dunno
S&SPhoto
Mar-17-2007, 11:45 AM
Well nevermind...I didnt figure out what the problem was, but it is working now :dunnoLooks good, Jared. What about putting your "personal galleries" in the navbar as well so that it's all tied together?
Samir
Jared
Mar-17-2007, 12:50 PM
Thanks Samir, as you can see I couldnt do it without your code :D
You know, I probably will move it, but I want to keep a small nav bar like the one that holds that link to use in some areas of my site. Eventually that one probably wont stay on the homepage, but Im still trying to figure this all out and get my portfolio uploaded. Thats my next priority then after that maybe you can help me with some other ideas I have...
Im new to this and all the code is making me a bit crazy :twitch but Im starting to understand how things work a little more. I barely passed C++ in college, but this is easier.
jeffreaux2
May-23-2007, 01:07 PM
I have created and added a banner as described here. I cannot figure out why the outer glow font does not show when hovering. Am I missing some code?
Any help would be appreciated.
Thanks
www.jkmann.com
jeffreaux2
May-23-2007, 01:08 PM
I have created and added a banner as described here. I cannot figure out why the outer glow font does not show when hovering. Am I missing some code?
Any help would be appreciated.
Thanks
www.jkmann.com (http://www.jkmann.com)
Here is the image
http://jkmann.smugmug.com/photos/154984964-O.gif
scwalter
May-23-2007, 06:06 PM
Here is the image
http://jkmann.smugmug.com/photos/154984964-O.gif
Looks very nice Jeff, try adding this code below your current panel items to get the glow effect.
/* Assign background to hover links and position it properly */
#panel1b a:hover {background: url(/photos/154984964-O.gif) 0px 0px no-repeat ;}
#panel2b a:hover {background: url(/photos/154984964-O.gif) -260px -60px no-repeat ;}
#panel3b a:hover {background: url(/photos/154984964-O.gif) -340px -60px no-repeat ;}
#panel4b a:hover {background: url(/photos/154984964-O.gif) -440px -60px no-repeat ;}
#panel5b a:hover {background: url(/photos/154984964-O.gif) -540px -60px no-repeat ;}
#panel6b a:hover {background: url(/photos/154984964-O.gif) -630px -60px no-repeat ;}
you can also make the active page glow similarly to above. Let me know if you want that and I'll try to help.
-Scott
scwalter
May-23-2007, 06:26 PM
Looks very nice Jeff, try adding this code below your current panel items to get the glow effect.
/* Assign background to hover links and position it properly */
#panel1b a:hover {background: url(/photos/154984964-O.gif) 0px 0px no-repeat ;}
#panel2b a:hover {background: url(/photos/154984964-O.gif) -260px -60px no-repeat ;}
#panel3b a:hover {background: url(/photos/154984964-O.gif) -340px -60px no-repeat ;}
#panel4b a:hover {background: url(/photos/154984964-O.gif) -440px -60px no-repeat ;}
#panel5b a:hover {background: url(/photos/154984964-O.gif) -540px -60px no-repeat ;}
#panel6b a:hover {background: url(/photos/154984964-O.gif) -630px -60px no-repeat ;}
you can also make the active page glow similarly to above. Let me know if you want that and I'll try to help.
-Scott
You didn't ask yet, but try this to indicate the current page in your navbar. I had to add a an extra line for panel4b for each of your subcategories, but I think it's working okay...
/* Set the navbar to indicate the current page */
.homepage #panel1b a, .homepage #panel1b a:active {background: url(/photos/154984964-O.gif) 0px 0px no-repeat ; cursor:text;}
.homepage #panel2b a, .homepage #pane21b a:active {background: url(/photos/154984964-O.gif) -260px 0px no-repeat ; cursor:text;}
.gallery_2885322 #panel3b a, .gallery_2885322 #panel3b a:active {background: url(/photos/154984964-O.gif) -340px -60px no-repeat ; cursor:text;}
.galleries #panel4b a, .galleries #panel4b a:active {background: url(/photos/154984964-O.gif) -440px -60px no-repeat ; cursor:text;}
.category_Portraits #panel4b a, .category_Portraits #panel4b a:active {background: url(/photos/154984964-O.gif) -440px -60px no-repeat ; cursor:text;}
.category_Wildcats #panel4b a, .category_Wildcats #panel4b a:active {background: url(/photos/154984964-O.gif) -440px -60px no-repeat ; cursor:text;}
.gallery_2858694 #panel5b a, .gallery_2858694 #panel5b a:active {background: url(/photos/154984964-O.gif) -540px -60px no-repeat ; cursor:text;}
.gallery_2857126 #panel6b a, .gallery_2857126 #panel6b a:active {background: url(/photos/154984964-O.gif) -630px -60px no-repeat ; cursor:text;}
Hope this helps,
Scott
jeffreaux2
May-24-2007, 03:24 AM
Thanks a billion Scott. I must admit I really like your site and banner. I had copied your code and worked on it last night at work. It works for the glow. I appreciate the help with the current page sticky. I will give it a shot.
How did you put the border around your slideshow?
jeffreaux2
May-24-2007, 03:42 AM
Forgot to ask.
Why do I get the tiny dotted line when I click on the buttons in the banner links? It looks tacky.
scwalter
May-24-2007, 03:06 PM
Thanks a billion Scott. I must admit I really like your site and banner. I had copied your code and worked on it last night at work. It works for the glow. I appreciate the help with the current page sticky. I will give it a shot.
Thanks.
How did you put the border around your slideshow?
There two ways (at least) to do it. The simplest way is to add the following to your CSS (assuming you're using BigWebGuy's slideshow hack:
#ssSlide { border: 10px solid #F0F0F0;}
#ssSlide is part of the slideshow variables, so this is all that is needed. The thing to note using this method is that the border will fade in and out with the slide, which you may or may not want. In my case, I put two slides side-by-side with the border built-into the image, so I want it to fade so it appears seamless.
If you want the border to remain and only have the slides fade, then you can add a border using the same technique as above, but apply it to the div containing the slideshow, in my case #SCWslideshow.
One more warning... all my slideshow images are the same size, I'm not sure what would happen if they were different. Try it and see what happens.
Why do I get the tiny dotted line when I click on the buttons in the banner links? It looks tacky.
I agreee, it's not pretty, but it only appears when clicking and I think this is a function of the browser and cannot be changed, but someone else more knowledgable may know how to get rid of it.
-Scott
Allen
May-24-2007, 04:20 PM
Forgot to ask.
Why do I get the tiny dotted line when I click on the buttons in the banner links? It looks tacky.
You using Firefox? If so it's the reason.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.