0

I have an OL list of numbered LI items. I want to put a left border around each separate LI element. However, I am only able to put the border to the right of the bullet number, and I want it to the left.

Here's the http://jsfiddle.net/z7gkLnc7/

I want to keep the div wrapper around the LI elements.

<ol>
    <div class = "li_wrapper">
        <li>I am a line</li>
    </div>
    <div class = "li_wrapper">
        <li>I am a line</li>
    </div> 
</ol>

Styles:

.li_wrapper{
    font-size:20px;
    margin-top:10px;
}

li{
    border-left:red 2px solid;
}
user984003
  • 28,050
  • 64
  • 189
  • 285

5 Answers5

4

Simply use:

Demo Fiddle

list-style-position: inside;

The list-style-position CSS property specifies the position of the marker box in the principal block box.

SW4
  • 69,876
  • 20
  • 132
  • 137
  • So what's the difference between this and your original fiddle ? They are showing up exactly the same on my Computer, That's why I though you had got confused with the left and right..... – Billy Dec 15 '14 at 12:20
0

Hay you can do it like this : Just change the padding-left, if you like the red line be more left.

.li_wrapper{
    font-size:20px;
    margin-top:10px;
}

li{
    border-left:red 2px solid;
    list-style-type: none;
    padding-left: 10px

}
AngularLover
  • 364
  • 1
  • 12
  • This removes the bullet, but I need the steps to be numbered. I made a jsfiddle of your solution, with bullets: http://jsfiddle.net/z7gkLnc7/1/ The red line is still not outside the bullet number. – user984003 Dec 15 '14 at 12:11
0

You need to set list-style to decimal as well. Then it's exactly what you need.

li  {
  border-left:red 2px solid;
  list-style: decimal inside;     /*append this line*/
}

JSFIDDLE

Kuba Rakoczy
  • 3,954
  • 2
  • 15
  • 16
0

You can achieve this by removing the normal numbers and add a pseudo class.

ol {
    counter-reset: li; /* Initiate a counter */
    list-style: none; /* No default numbers */
    *list-style: decimal; /* Fallback for IE6/7 */
}

Then add a number before you your element in your li (for example wrap it in a span:

.li span:before{
    content: counter(li);
    counter-increment: li;
    /* Add your styles like border-left */
}

Roger Johansson wrote about that for further information!

Marian Rick
  • 3,350
  • 4
  • 31
  • 67
0

add content , like this

#one li::before{content:" ";border-left:2px solid red;}
<ol id="one">

        <li> I am a line</li>
    
        <li> I am a line</li>
    
</ol>
Billy
  • 2,448
  • 1
  • 10
  • 13