R
R
rondew2011-09-18 18:54:05
css
rondew, 2011-09-18 18:54:05

How to arrange list items in a row of two items?

there is an unordered list of six items. I need every third item inside the container to wrap to the next line. that is, you need to get three columns of two items. I lost my feet looking for something (

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Ano, 2011-09-19
@rondew

<style>
    li { float: left; margin: 1em; }
    li:nth-child(2n+1) { clear: both; }
</style>
<ul>
    <li> 1
    <li> 2
    <li> 3
    <li> 4
    <li> 5
    <li> 6
</ul>

C
cthtuf, 2011-09-19
@cthtuf

If it is possible to edit the script, then assign a class to every fourth element, and that's it.
If it is not possible, then add a class to every fourth element of the list through js.

K
Kakysha, 2011-09-18
@kakysha

Maybe I'm a layman, of course, but I came to the conclusion yesterday that it's impossible to do this with one css. Correct me if I'm wrong, the author and I will be grateful to you. I solved only by splitting into several lists.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question