So I am trying to figure out how I can vertically align some text that I have with a custom bullet image. Here is what I have:
<ul>
<li>LINE OF TEXT</li>
<li>LINE OF TEXT</li>
<li>LINE OF TEXT</li>
</ul>
And for the CSS...
#div .class
{
color: #4c361c;
font-size: 13px;
list-style-image: url(../images/image.png);
}
#div .class li{ }
Does anyone have anyideas on how to go about doing this?
Inorder to make vertical-align: middle; work, you need to use display: table; for your ul element and display: table-cell; for li elements and than you can use vertical-align: middle; for li elements. You don't need to provide any explicit margins , paddings to make your text vertically middle.
If you want to make a text appear vertically aligned next to a Font Awesome icon, you can use the CSS vertical-align property set to “middle” and also, specify the line-height property. Change the size of the icon with the font-size property.
We need to create a parent element that contain both image and text. After declaring the parent element as flexbox using display: flex; we can align the items to the center using align-items: center;. Example: This example uses flexbox to vertically align text next to an image using CSS.
Here's a demo.
Using a background image can get you the desired effect.
HTML
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
</ul>
CSS
ul {
list-style: none;
}
ul > li {
background: url('../imgpath/bullet-image.png') no-repeat left center;
/* Adjust the padding for your custom bullet image */
padding: 10px 0 10px 34px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With