Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS css sprite for navigation not working!

  • This topic is empty.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #33070
    roncito
    Member

    made a navbar using images cut out from PS and i cant get it to work? Dont know what im doing wrong. Img size is 469px by 104px. Heres my code.

    css:
    #nav {background: url(../nav-bar.png)no-repeat ; height: 48px; width: 468px; position: absolute; top: 225px; left: 180px;

    margin: 0; padding: 0; }

    #nav span {
    display: none;
    }

    #nav li, #nav a {
    height:48px;
    display:block;
    }

    #nav li {
    float:left;
    list-style:none;
    display:inline;
    }

    #nav-example-01 {
    width: 91px;
    }
    #nav-example-02 {width: 107px;}
    #nav-example-03 {width: 138px;}
    #nav-example-04 {width: 126px;}

    #nav-example-01 a:hover {background: url(../nav-bar.png) 0 -48 no-repeat; }
    #nav-example-02 a:hover {background: url(../nav-bar.png) -198px -48px no-repeat; }
    #nav-example-03 a:hover {background: url(../nav-bar.png) -336px -48px no-repeat; }
    #nav-example-04 a:hover {background: url(../nav-bar.png) -462px -48px no-repeat; }

    sorry for using all this space and thanks for any help .
    ron

    #73548
    roncito
    Member

    Sorry but right now i don’t have it on a server. This is the first time trying this method. any other way to do it? thanks

    #73549
    roncito
    Member

    also the imiage that im using is a png24, its tranparent. i dont know if that makes a difference either?
    Ron

    #73524
    roncito
    Member
    #73526
    chrisburton
    Participant

    …You absolutely do not need an image for this.

    #73411
    roncito
    Member

    thanks for the suggestion,
    I’ll give it a try.
    Ron

    #73413
    TheDoc
    Member

    @fordinary

    page-id-7 #nav li.Projects a {
    /* shift background position */
    }
    #73398
    TheDoc
    Member

    You’d have to do this:
    background-position: 0 -47px;

    #73382
    TheDoc
    Member

    Oops! You’re missing the . in front of page-id-5.

    .page-id-5 #nav li.About-Me a

    #73341
    furrball1383
    Member

    dude i agree with Christopher Burton, you do not need an image for this, simply have your font styles set up for your list items and then have the onhover and onclick commands set the colors of said list items to the new colors

    #73338
    chrisburton
    Participant

    if that is what roncito is after then the image sprite is the best method to be using

    False. In no way do you need to use an image to change color and use an underline on a hover event.

    #73335
    chrisburton
    Participant

    @sl1dr: I completely understood your point but I believe it is naive and unless his graphic was significant enough not able to produce through code, I would certainly not use an image. There are other ways to help with fallback.

    #73129
    roncito
    Member

    thanks guys for the help. it works either way for me.

Viewing 13 posts - 1 through 13 (of 13 total)
  • The forum ‘CSS’ is closed to new topics and replies.