Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List item marker and list item text are not aligning

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");

}
like image 581
John Sonderson Avatar asked Sep 26 '22 18:09

John Sonderson


1 Answers

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

like image 160
Michael Benjamin Avatar answered Sep 30 '22 06:09

Michael Benjamin