Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Can someone point me to a tutorial?

  1. #1
    Join Date
    Apr 2008
    Posts
    84
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Can someone point me to a tutorial?

    If this can be done, of course.

    What I want to do is make a horizontal navigation across the top of my page, with images that will change on rollover.

    I know it can be done with javascript, but I just want to see if I can do it with only CSS.

    The link images are all different widths (different words).
    I've made all the link images with a split image, with what I want for the initially displayed image at bottom, and the rollover image at top, so I can use it as the background, and push the background down on rollover, if this is possible.

    Similar to http://www.dynamicdrive.com/style/cs...vertical_menu/
    but that example uses plain text, and the same image for the background on all, and it's vertical.
    I will use no text, as the images say what the links are.

    I would imagine there's a tutorial on it somewhere, so you wouldn't have to explain it all here. (?)

    Thanks in advance.
    Last edited by Geezer D; 11-07-2008 at 08:55 PM.

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    http://www.seoconsultants.com/css/menus/tutorial/

    Might be worth looking at, or just search

    "how to make css horizontal menu" in google, good luck,

    Jack.

  3. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    i think if you set a background image for the "a {" and then for "a:hover{" the other image. This will flip from one image to the other when the mouse is on it and you can put text over it.

  4. #4
    Join Date
    Apr 2008
    Posts
    84
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by bluewalrus View Post
    i think if you set a background image for the "a {" and then for "a:hover{" the other image. This will flip from one image to the other when the mouse is on it and you can put text over it.
    I don't want any text, though. The image says what the link is.

  5. #5
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Ok, here's what you could do:

    CSS:

    Code:
    .link{
    background:url(images/buttons/image.png) no-repeat;
    }
    .link:hover{
    background:url(images/buttons/image_over.png) no-repeat;
    }
    Then for the HTML you would put this:

    Code:
    <a class="link" href="index.html"></a>
    Hope this helps you,

    Jack

  6. #6
    Join Date
    Apr 2008
    Posts
    84
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    That uses 2 different images, and doesn't specify any width, or move the background.
    Doesn't do anything as I described.

    Here's one of the link images:

    They're all 80px tall, so I need to somehow make each li (list item) box 40px tall, but all with their own width, since they each say different words.
    It would have the bottom part showing for the background, then the top would show on hover.

    Or maybe I can't do it with a background, since the li will be empty?

    Maybe put the image in the li, and somehow move it down on hover?
    Last edited by Geezer D; 11-07-2008 at 06:36 PM.

  7. #7
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Oh I see what you mean, then maybe you can use this (since I don't know what images you're working with you'll have to adjust it to your needs), also note that it's better to use a horizontal image that moves left or right on rollover than one that moves up or down:

    CSS:

    Code:
    .link{
    background: url(image.png) no-repeat;
    background-position: 3px 5px;
    }
    
    .link:hover{
    background: url(image.png) no-repeat;
    background-position: 3px -85px;
    }
    Then just adjust the width according to how big the image you're working with is.

    Here's also a link explaining in more detail: http://www.tanfa.co.uk/css/examples/...o-preload2.asp

  8. #8
    Join Date
    Apr 2008
    Posts
    84
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    OK, so then repeat that for each one, and replace where it has "link" with the name of that link (like "about" and "images/about.png")?

  9. #9
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Quote Originally Posted by Geezer D View Post
    OK, so then repeat that for each one, and replace where it has "link" with the name of that link (like "about" and "images/about.png")?
    Yea, so replace "index.html" with whatever page you want, and then replace the url(image.png) with wherever you image is stored and change the CSS positioning to suit how tall your images are, so if it's 80px you probably need to move it 40px down (if it was exactly half and half), but just change it to suit you,

    say if you have any more problems.

  10. #10
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    After taking your "about.png" image I have modified the CSS, here is what you need to get it to work:

    CSS:

    Code:
    a.link, a.link:visited{
    background: url(about.png) no-repeat;
    background-position: 0px 0px;
    display: block;
    width: 125px;
    height: 40px;
    text-decoration: none;
    }
    
    a.link:hover{
    background: url(about.png) no-repeat;
    background-position: 0px -40px;
    }
    Then the HTML:

    Code:
    <a class="link" href="home.html"></a>
    Hope this works for you.

    Jack.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •