开发者

Align these ordered list and list element in a horizontal line

开发者 https://www.devze.com 2023-04-03 01:30 出处:网络
I have the following HTML code: <div> <ol class=\"sortable\"> <li id=\"list_1\" class=\"nob\"><div>A</div>

I have the following HTML code:

<div>
  <ol class="sortable">
    <li id="list_1" class="nob"><div>A</div>
      <ol>
        <li id="list_2"><div>1</div></li>
        <li id="list_3"><div>2</div></li>
        <li id="list_4"><div>3</div></li&g开发者_JS百科t;
        <li id="list_5"><div>4</div></li>
      </ol>
    </li>
    <li id="list_6" class="nob"><div>B</div>
      <ol>
        <li id="list_7"><div>1</div></li>
        <li id="list_8"><div>2</div></li>
      </ol>
    </li>
  </ol>
</div>

I want the output to be as :

|A|1|2|3|4|B|1|2|

Can anyone help me write the CSS for the same?

Thanks.


Basic solution:

.nob, .nob div, .nob ol, .nob li { display: inline; /* or inline-block */ }

Use inline if you don't need to control vertical margins. Otherwise you should consider using inline-block.


.sortable li, .sortable li div, .sortable li ol  {
    float:left;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消