I'm trying to build my first responsive layout. I want to display list items in a vertical line, depending on width.
<div style="height:800px;">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
</ul>
</div>
1 5 2 6 3 7 4
If the browser gets resized, I want it to become
1 4 7 2 5 3 6
Can someone help me? I've been trying for hours and I can't get anything. I've tried using tables but I can't do it like that either.
You can do that using CSS3.
Here is the HTML code snippet:
& Here is the CSS3 code snippet :
If you take a look at the following example - it uses fixed width columns, and I think this is the behavior requested.
http://www.vanderlee.com/martijn/demo/column/
If the bottom example is the same as the top, you don't need the jquery column plugin.
Thank you for this example, SPRBRN. It helped me. And I can suggest the mixin, which I've used based on the code given above:
Using:
This can be done using CSS3 columns quite easily. Here's an example, HTML:
Create a list with as many list elements as you want. Then enclose the list in a div, setting style=column-width and style=column-gap, to match the information in your list elements. Do not set style=columns. Totally responsive list that adapts to screen size. No plugins required.
Use column-width property of css like below