List item marker and list item text are not aligning
Asked Answered
T

1

6

I am getting the following result in my web browser:

enter image description here

The checkmarks appear slightly raised with respect to the text, but I would like the text to be all lined up. What should I do?

I have the following HTML:

<ul class="train">
  <li>
    <p><?php echo $pageContents->getContents("comptrainLI1"); ?></p>
    <ul class="traininner">
      <li>HTML</li>
      <li>CSS</li>
      <li>JavaScript</li>
      <li>jQuery</li>
      <li>PHP</li>
      <li>SQL</li>
      <li>WordPress CMS</li>
      <li>Magento CMS</li>
    </ul>
  </li>
  <li>
    <p><?php echo $pageContents->getContents("comptrainLI2"); ?></p>
    <ul class="traininner">
      <li>C</li>
      <li>C++</li>
      <li>C#</li>
      <li>Java</li>
    </ul>
  </li>
</ul>

and CSS:

div#mainContent ul.train {

  list-style-position: inside;

  list-style-image: url("../images/checkmark-round-whiteOnGreen.jpg");

  font-size: 18pt;

}

div#mainContent ul.train ul.traininner {

  padding-left: 20px;

  list-style-image: url("../images/checkmark-round-whiteOnGreen.jpg");

}
Truax answered 12/9, 2015 at 20:24 Comment(3)
I am not quite sure this can be done. I suggest you to set list-style-image: none and instead set background-image to li tag. You can easily configure background-position and li elements padddingAirlee
vertical-align: top on all li??Trinitytrinket
the problem is the bullet is acting as a line.Alphonsoalphonsus
G
7

I don't think it's possible to know the reason for the misalignment based on the limited code you posted in your question. It could be something in your PHP. So I've posted a general solution.

li {
    list-style-type: none;
    margin-bottom: 5px;
}

ul.traininner li::before {
    content: '';
    display: inline-block;
    vertical-align: bottom;
    padding: 10px 20px 0 0;
    height: 10px;
    width: 10px;
    background-image: url("http://i.imgur.com/F05JSPD.png");
    background-repeat: no-repeat;
}
<ul class="train">
  <li>
    <ul class="traininner">
      <li>HTML</li>
      <li>CSS</li>
      <li>JavaScript</li>
      <li>jQuery</li>
      <li>PHP</li>
      <li>SQL</li>
      <li>WordPress CMS</li>
      <li>Magento CMS</li>
    </ul>
  </li>
  <li>
    <ul class="traininner">
      <li>C</li>
      <li>C++</li>
      <li>C#</li>
      <li>Java</li>
    </ul>
  </li>
</ul>

jsFiddle

Goodwife answered 12/9, 2015 at 20:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.