Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I vertically offset a bullet or content in CSS?

Tags:

html

css

See this image:
Bullets

It's a little off-kilter, and I'd like to move the content up, or the bullet itself down. I've tried padding, margin and positioning to no avail.

like image 972
Doug Smith Avatar asked Sep 06 '12 17:09

Doug Smith


People also ask

How do you vertically align items in CSS?

The vertical-align property in CSS controls how elements set next to each other on a line are lined up. In order for this to work, the elements need to be set along a baseline. As in, inline (e.g. <span> , <img> ) or inline-block (e.g. as set by the display property) elements.

How do you align bullets in CSS?

By using the css list-style-position property and setting that to “inside” our bullets move to the inside of our list element, and in combination with the padding of 0 our list align perfectly with the rest of our text.

How do you put a space between bullets and text in CSS?

We use CSS padding-left property, to create a space between bullets and the text. It is used to set the padding area on the left of an element. HTML support ordered list, unordered list and HTML support ordered list, unordered list and we must use the <ul> tag, to create unordered list in HTML.

How do I vertically align text in a div using CSS?

The CSS just sizes the div, vertically center aligns the span by setting the div's line-height equal to its height, and makes the span an inline-block with vertical-align: middle. Then it sets the line-height back to normal for the span, so its contents will flow naturally inside the block.


2 Answers

Try setting the vertical-align property on the list items. Possible values are:

baseline | sub | super | text-top | text-bottom | middle | top | bottom | <percentage> | <length>

jsFiddle example

HTML

<ul>
    <li>a</li>
    <li>b</li>
    <li>c</li>
</ul>

CSS

ul {
    list-style-image: url(http://cdn1.iconfinder.com/data/icons/c9d/check.png);
}
li {
    vertical-align:top;   
}
​
like image 140
j08691 Avatar answered Oct 18 '22 11:10

j08691


You could try to set line-height equal to the height of the image

like image 27
Jørgen Avatar answered Oct 18 '22 09:10

Jørgen