skip to Main Content

I have a bullet list with an image as the bullet point and have it coded like as shown in the snippet:

li::before {
  content: "";
  display: inline-block;
  height: 15px;
  width: 15px;
  background-size: contain;
  background-image: url('https://adp-com-prod.es.ad.adp.com/-/media/apps/wfn/images/rs_email_checklisticon-bullet.png?rev=f7aed74…&hash=2EB10B8B4C4FCB24BC37B1E501219BBB');
  background-repeat: no-repeat;
  margin-right: 7px;
  background-position: center center;
  vertical-align: middle;
}
ul {
  padding-left: 0;
  list-style: none;
}
       <ul class="voe-list">
                <li>
                  <strong>Simplicity.</strong> this is bullet number one with a longer sentence so it goes on the second line. Stay tuned for bullet number 2.
                </li>
                <li>
                  <strong>Compliance.</strong>this is bullet number one with a longer sentence so it goes on the second line.Stay tuned for bullet number 3. 
                </li>
                <li>
                  <strong>Flexibility.</strong>this is bullet number one with a longer sentence so it goes on the second line.Stay tuned for bullet number 4.
                </li>
              </ul>

As you can see each bullet copy is not aligned and the second line starts where the check mark starts. any way we can do it so it aligned with the first word of the first line? I could add padding-left or margin-left but wanted to see if there was another way.

In the default unordered list, it does align since the list-style lies in the tag (see screenshot)

enter image description here

2

Answers


  1. If you add negative margin to counteract the margin you’ve added you get the desired result.

    (I added a bullet image from the web so you can see the list layout is working how you are intending)

    li::before {
      content: "";
      display: inline-block;
      height: 15px;
      width: 15px;
      background-size: contain;
      background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAbFBMVEX///8AAAD4+PjV1dW8vLyrq6tJSUkxMTGMjIyCgoLf39+2traioqKJiYnw8PCurq4WFhZsbGyZmZnNzc1VVVXp6el0dHQ3NzdOTk5iYmLy8vIhISHIyMjj4+MZGRk+Pj4LCwspKSlaWlqVlZXFEyvtAAADlElEQVR4nO3diVrqMBAF4AaVRXBBAcENi+//jrfwXdHK0qSZ5EzH8z9BzgeFmTRLURARERERERERERERERERERERERFRp8zHw1W/v1wNx3P0UFLoTQbu29Okhx6QsN6N++3GVMbLg3xbV+hhyV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AAABJRU5ErkJggg==');
      background-repeat: no-repeat;
      margin-right: 7px;
      margin-left: -25px;
      background-position: center center;
      vertical-align: middle;
    }
    ul {
      padding-left: 0;
      list-style: none;
      margin-left: 25px;
    }
    <ul class="voe-list">
                    <li>
                      <strong>Simplicity.</strong> this is bullet number one with a longer sentence so it goes on the second line. Stay tuned for bullet number 2.
                    </li>
                    <li>
                      <strong>Compliance.</strong>this is bullet number one with a longer sentence so it goes on the second line.Stay tuned for bullet number 3. 
                    </li>
                    <li>
                      <strong>Flexibility.</strong>this is bullet number one with a longer sentence so it goes on the second line.Stay tuned for bullet number 4.
                    </li>
                  </ul>
    Login or Signup to reply.
  2. I understand what you’re trying to do, but li::before is not how you change the bullet point. With what you have, all you’re doing is adding the image at the front of every <li>, so it actually is aligning correctly.

    To fix it, get rid of that li::before style entirely. You can change the bullet of a <ul> using the list-style property and url().

    ul {
      /* padding-left: 0; */
      /* list-style: none; */
      list-style: url('https://adp-com-prod.es.ad.adp.com/-/media/apps/wfn/images/rs_email_checklisticon-bullet.png?rev=f7aed74…&hash=2EB10B8B4C4FCB24BC37B1E501219BBB');
    }
    

    Does that fix your problem?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search