80

I am trying to use :before and :after with list but it is not working. I am sure it's a simple mistake but I am not able to point it out.

Any help would be appreciated

Please check the fiddle

<div class="org-chart">
  <ul class="chart chart-prhead">
    <li>
      <span><a href="#">Dabba</a></span>
      <ul class="chart-mgr">
        <li>
          <!-- level 2 -->
          <span><a href="#">Dabba</a></span>

        </li>

      </ul>
    </li>
  </ul>
</div>
.chart ul:after {
  border: 1px solid #f30;
}
.chart li span:after {
  border: 1px solid #eee;
}
.chart li span:before {
  border: 1px solid #ccc;
}
.chart li a:after {
  border: 1px solid #666;
}
.chart li a:before {
  border: 1px solid #333;
}
Igor Ivancha
  • 3,413
  • 4
  • 30
  • 39
Tom
  • 1,779
  • 2
  • 15
  • 19
  • Your link is broken, but it looks like you have no `content` and no styling to make them large enough to have borders. You might actually want `border-left` and `border-right`. – Alexander O'Mara Feb 03 '16 at 14:59
  • I have voted to repoen, I had an issue that was not covered by the duplicate question. I think this question is open, the other only has to do with "content" – Jamie Hutber Sep 15 '20 at 10:59

2 Answers2

215

If you want :before and :after to work, you need to give them content, otherwise they don't really 'exist'. The easiest thing to do is, in the css, set content: '' for both pseudoelements.

Igor Ivancha
  • 3,413
  • 4
  • 30
  • 39
GMchris
  • 5,439
  • 4
  • 22
  • 40
25

You should use :before and :after selectors with content property:

.chart ul:after{
  content: "";
  border:1px solid #f30;
}
Enver Dzhaparoff
  • 4,341
  • 3
  • 19
  • 21