Forums

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

Home Forums CSS Want to align text in list vertically

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #44774
    Rohithzr
    Participant

    i hav this code

    • abcde
    • zxcvb

    and this css

    ul li{
    list-style-image:”src”;
    list-style-position:”inside”;
    }

    the problem is that this text here is aligned at the bottom
    i want it centered

    #135062
    Rohithzr
    Participant

    i dont know code option is not working for some reasons

    #135070
    Alen
    Participant

    You mean something like this: http://codepen.io/anon/pen/ugEje

    #135078
    CrocoDillon
    Participant

    I’m guessing the list-style-image is taller than the height of the li without the image and the text is baseline aligned with this image. Vertical-align doesn’t seem to work so I’m lost (without extra markup that is).

    #135086
    unasAquila
    Participant

    just give it equal padding top and bottom this should correct for any image size issues i.e :

    padding: 0.3em 0em;

    #135107
    ElijahFowler
    Participant

    Create a [Codepen](http://codepen.io/ “Codepen or it didn’t happen!”) and we can get you fixed up. ;)

    Also, the code option requires that you select all the text that you want in the code box. Just a tip. ;)

    HTH,

    -Elijah

    #135150
    Rohithzr
    Participant

    @AlenAbdula well not really iam using an image of about 34px as my list style


    @Dillion
    well vertical align neva works i always end up using tables in such cases


    @unasAquila
    no it doesnt seem to work for me coz it gives padding to whole li including the image bullet so it does not work


    @Elijah
    creating a pen but replace it with a image of 36*36 px then work around it
    and thanx for code issue i was using it as tags… my bad

    [pen](http://codepen.io/anon/pen/bkdny “pen”)

    #135153
    Paulie_D
    Member

    The answer is to not use `list-style-image` as, as you have discovered, this causes issue with the text alignment.

    Instead use the image as a bg image like this: http://codepen.io/anon/pen/KIheg

    #135157
    unasAquila
    Participant

    Or using `list-style-image`

    [link](http://codepen.io/unasAquila/pen/botkC)

    #135169
    CrocoDillon
    Participant

    > Or using list-style-image

    That has nothing to do with `list-style-image` but with setting line height equal to image height, breaks if the text is more than 1 line.

    #135176
    Paulie_D
    Member

    >setting line height equal to image height

    Doesn’t always work…see my Codepen

    #135184
    Rohithzr
    Participant

    @Paulie D kinda workd for me man … thanks a lot now i can get rid of the tables i created

    > setting line height equal to image height

    i tried line height and image height
    but didnt work the pen is perfect… atleast for my problems

    #135186
    ChinmayDey
    Participant

    You can use the contains within a `` or `

    ` or another tag and use line-heights css for this tag.

    #135188
    Paulie_D
    Member

    >ChinmayDey

    That’s just unnecessary mark-up.

    #135255
    Rohithzr
    Participant

    just wanted to know if theres any method to display a couple of backgrounds in an li
    the thing is that the image bullet (converted to background)
    now i want that on hover it display a blue bar of selection in background without removing the bullet background

    currently i am achieving it through another background which i photoshoped (the bullet image and bar image together) and am changing the bg image on hover

    any better way of doing it?

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