Back Home

Open Designs

Community. Driven.

    • CommentAuthorzanzibar
    • CommentTimeJul 14th 2008
     
    I am using an image instead of a bullet with my ul li tags and have run into a problem with the position of the image with regard to the text.

    Does anyone know how I can get the image to move down or the text to move up?

    The HTML is just regular ul li tags
    The CSS is:
    ul li{
    list-style-type: square;
    list-style-image: url(../images/house.gif);
    padding: 0 0 5px 5px;
    }

    and it looks like this
    • CommentAuthorfernbap
    • CommentTimeJul 14th 2008
     
    use the image as background, like:

    ul li {
    list-style: none;
    padding: 0 0 5px 15px;
    background: transparent url(../images/house.gif) left bottom no-repeat;
    }
  1.  
    Just like how you can do padding: 0 0 0 0; you can do that for images.. That's what I remember doing when I had that problem atleast..
    • CommentAuthorwfiedler
    • CommentTimeJul 14th 2008
     
    Better:

    ul li {
    list-style: none;
    padding: 0 0 5px 15px;
    background: transparent url(../images/house.gif) no-repeat 0 5px;
    }

    The value in red moves the background image down. Try different values.
    • CommentAuthorzanzibar
    • CommentTimeJul 14th 2008
     
    Thanks everyone for the input, I tried that but now the images are indented too far and are under/over the text. I have played around with negative values on the background image but that makes the image disappear entirely.

    It seems as though the text is indenting to the same degree as the images, any ideas????
    • CommentAuthorzanzibar
    • CommentTimeJul 14th 2008
     
    OK I get it, the image as a background is appearing under the text, it is not taking the place of the bullet, so I need a way to indent the text past the image or make the image appear in place of the bullet. This is what was happening with my original way of doing it.
    • CommentAuthorzanzibar
    • CommentTimeJul 14th 2008
     
    OK I fixed the image problem now it sits opposite the text but it indents too far, as I said above the background image is not replacing the bullet.

    This is my CSS now, not very elegant - any ideas on the indentation?

    # ul li{
    list-style: none;
    height: 20px;
    background: transparent url(../images/house.gif) no-repeat 0 0;
    margin: 10px 0;
    }

    # li{
    padding: 3px 0 0 30px;
    }
    • CommentAuthorMike Weiss
    • CommentTimeJul 14th 2008
     
    Use a negative margin.

    # ul li{
    list-style: none;
    height: 20px;
    background: transparent url(../images/house.gif) no-repeat 0 0;
    margin: 10px 0 10px -30px;
    }

    # li{
    padding: 3px 0 0 30px;
    }
    • CommentAuthorzanzibar
    • CommentTimeJul 16th 2008
     
    Cool, that works. Thanks