Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE list-style-position:inside issues

Hi I'm having issues with list-style-position: inside when using IE. On Firefox or Chrome it does not seem to have this problem.

ol.myList { list-style-position:inside; }
ol.myList li { padding:20px 10px; font-weight:bold }
ol.myList li p { font-weight:normal }
<ol class="myList" start="1">
    <li>
        <h4>My Title</h4>
        <p>My Details</p>
    </li>
</ol>

On Chrome/Firefox it shows like this:

1. My Title
My Details

But on IE it shows this:

1.
My Title
My Details

Any suggestion in order to get it to work on IE?

like image 687
Osirus Avatar asked Mar 17 '14 18:03

Osirus


People also ask

Can I use list-style-position inside?

list-style-position: inside; means that the bullet points will be inside the list item. As it is part of the list item, it will be part of the text and push the text at the start: Coffee - A brewed drink prepared from roasted coffee beans...

Can we specify the style and position of the list item marker?

list-style-type: It is used to specify the type of list-item marker in a list. list-style-position: It is used to specify the position of the list-item markers.

How do you use a list-style-position?

The list-style-position property specifies the position of the list-item markers (bullet points). list-style-position: outside; means that the bullet points will be outside the list item. The start of each line of a list item will be aligned vertically: Coffee - A brewed drink prepared from roasted coffee beans...

What are the two values of the list-style-position property?

The list-style-position property defines where to position the list marker, and it accepts one of two values: inside or outside.


2 Answers

This is an inconsistency among browsers. Firefox displays the number/bullet on a separate line, as does IE.

Use display: inline-block on the h4 and *display: inline; zoom: 1; for IE7.

ol.myList li h4 {
    display: inline-block;
    *display: inline;
    zoom: 1;
}

Quote from the Mozilla documentation regarding this issue: https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-position#Browser_compatibility

N.B. There is variance among browsers regarding behaviour when a block element is placed first within a list element declared as list-style-position:inside. Chrome and Safari both place this element on the same line as the marker box, whereas Firefox, Internet Explorer and Opera place it on the next line. For more information on this, see this Mozilla Bug report and an example.

like image 139
Aleksander Bavdaz Avatar answered Oct 24 '22 00:10

Aleksander Bavdaz


Ah Pek, try this:

ol.myList li h4 { display: inline-block; }

or

ol.myList li h4 { display: inline; }
like image 32
Leann Avatar answered Oct 24 '22 00:10

Leann