Images in navi

This is a discussion on "Images in navi" within the Web Page Design section. This forum, and the thread "Images in navi are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Dec 9th, 2006, 19:29
Reputable Member
Join Date: Sep 2006
Location: Rothwell
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Question Images in navi

Hi Guys!

I have a question. I know how to do the rollover in navigation, but now i would like to use images instead of letters.
I have this 2 images the darker one is for the link, and the white one is when you hover over the link. I just cant make it work.
Can you guys please help me!

Thank you in advance!
Attached Images
File Type: png navihome.png (36.2 KB, 62 views)
File Type: png hoverhome.png (35.5 KB, 56 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Dec 9th, 2006, 20:20
Reputable Member
Join Date: Nov 2006
Location: London, England
Age: 15
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

if the home tab was 'home.gif' and the dimensions 100x30, the code (i think) would go summat lyk this:
The HTML:
Code: Select all
<div class="rollover"> 
         <li>
           <a href="home.html"><img src="home.gif"        width="100" height="30" border="0"></a>        
         </li>
      </div>
The CSS:
Code: Select all
 
<style type="text/css">

.rollover a { display:block; width:32px; background-color: #FFFFFF}
.rollover a:hover { img: url(home2.gif)}
#nav-menu ul
{
list-style: none;
padding: 0;
margin: 0;
}

</style>
I AM A BIT OF A NOOB,
so this may not work.

Last edited by Dapandyman; Dec 9th, 2006 at 20:53.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Dec 9th, 2006, 21:43
Reputable Member
Join Date: Sep 2006
Location: Rothwell
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

I tried it but no success, but thank you anyway.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Dec 9th, 2006, 21:50
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

Use the background switch method. Combine those two images so one is above the other.

Code: Select all
<a href="/" title="home" id="home">Home</a>
Code: Select all
a#home {
    width: 100px;
    height: 20px;
    text-indent: -5000px;
    background: #fff url("home.gif") no-repeat 0 0;
    display: block;
}
a#home:hover {
    background-position: 0 100%;
}
I can't remember if text-indent works inside <a> tags. If it doesn't, just apply text-indent: -5000 px; to the <ul> that the links are in.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Dec 9th, 2006, 21:52
Reputable Member
Join Date: Nov 2006
Location: London, England
Age: 15
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

i told you i was a noob... lol
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Dec 9th, 2006, 21:56
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

You had the general idea, but the background switch method is better because it only loads one image so there is no flicker or need to preload.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Dec 9th, 2006, 22:05
Reputable Member
Join Date: Sep 2006
Location: Rothwell
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

I will try it now.
...other q may sound stoopid : does it matter if i use class or id? and should i use gif instead of png?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Dec 9th, 2006, 22:11
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

No, it doesn't really matter whether you use an ID or a class. ID's are good for anchors and JavaScript. Classes are actually more widely supported.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Dec 9th, 2006, 22:54
Reputable Member
Join Date: Sep 2006
Location: Rothwell
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

I tried it but it still not working....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Dec 9th, 2006, 23:08
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

http://ryanfait.com/css/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Dec 10th, 2006, 02:55
Elite Veteran
Join Date: Dec 2005
Location: On Internet
Posts: 4,859
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

Post the page up here, and we can trouble shoot, and see what you did wrong in the code...lol
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Dec 10th, 2006, 09:02
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

The link I gave you is an example in case you missed it for some reason
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Dec 10th, 2006, 10:43
Reputable Member
Join Date: Sep 2006
Location: Rothwell
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

I tried to modify the link you gave me Ryan, but i have no luck. Anyway, here is the link. http://www.flowerinstyle.co.uk/try.html.
As you see i have those images as navi buttons but i would like to have the white ones when hover.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Dec 10th, 2006, 12:51
Up'n'Coming Member
Join Date: Jun 2006
Location: Northern Ireland, United Kingdom
Age: 22
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

Ryan I was wondering if you could explain that example to me, or listen to mine and then fill in the blanks, just hitting a wall whenever I get to a certain point!

Ok, so in the HTML you've set up your list items with links in them, named them appropriately and so on, and you've also given them text values of Home. Now in the CSS you've specified that any link in a list item will be indented off the page, so does that mean the the Text link in the link is wayyy off the page? You also specified that the background for each class is the appropriate gifs so does that mean, that only the gif will be seen, as the text is off-screen? I don't understand the hover part so perhaps you could explain that to me?

Thanks in advance,

Antwan

Last edited by Antwan; Dec 10th, 2006 at 12:53. Reason: Hit the enter button instead of space : )
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Dec 10th, 2006, 15:58
Reputable Member
Join Date: Sep 2006
Location: Rothwell
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

Ok! I have manage to do it! Here is the link http://www.flowerinstyle.co.uk/try.html
Thank you guys!
My other question is: how can i make the navigation, that Home will be the first and than galery and contact us?
Thank you 4 ur help!

Last edited by chubbs; Dec 10th, 2006 at 16:21.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Dec 10th, 2006, 16:00
Reputable Member
Join Date: Nov 2006
Location: London, England
Age: 15
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

yeah, the swapping's very smooth
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #17  
Old Dec 10th, 2006, 17:39
New Member
Join Date: Dec 2006
Location: Louisville, Kentucky
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

Hi Chubbs,

The technique you're going after is tricky depending upon your doc-type. What I can do is recreate what I use on my websites.

Give me tomorrow and I'll post.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #18  
Old Dec 10th, 2006, 17:57
Reputable Member
Join Date: Sep 2006
Location: Rothwell
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

I've done it already check the link above...
But thank you !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #19  
Old Dec 10th, 2006, 18:07
New Member
Join Date: Dec 2006
Location: Louisville, Kentucky
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

Hey Chubbs,

I noticed you did get it "functioning" but; There is a cleaner way of doing it. To keep the XHTML and CSS clean as intended by its' purpose of separating content and design.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #20  
Old Dec 10th, 2006, 18:37
Reputable Member
Join Date: Sep 2006
Location: Rothwell
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Images in navi

ohh... ok, so if you can post it later please? iwould like to see it.
Thank you!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply