How do I imitate having two list of items, while having only one list in css?

Inc33

Basically I have an <ul> with some <li> inside, from which I'm trying to create 2 separate blocks:

<ul>
    <li class="group1">List 1</li>
    <li class="group1">List 1</li>
    <li class="group2">List 2</li>
    <li class="group2">List 2</li>
    <li class="group1">List 1</li>
    <li class="group2">List 2</li>
    <li class="group1">List 1</li>
    <li class="group1">List 1</li>
    <li class="group2">List 2</li>
    <li class="group2">List 2</li>
    <li class="group2">List 2</li>
    <li class="group1">List 1</li>
</ul>

What I would like to achieve here, is to basically have 2 blocks side by side separated based on the groupN classname

Note: I do not want to use any javascript for this

Paulie_D

CSS-Grid can do that

ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-flow: column;
}

.group1 {
  grid-column: 1;
}

.group2 {
  grid-column: 2;
}
<ul>
  <li class="group1">List 1</li>
  <li class="group1">List 1</li>
  <li class="group2">List 2</li>
  <li class="group2">List 2</li>
  <li class="group1">List 1</li>
  <li class="group2">List 2</li>
  <li class="group1">List 1</li>
  <li class="group1">List 1</li>
  <li class="group2">List 2</li>
  <li class="group2">List 2</li>
  <li class="group2">List 2</li>
  <li class="group1">List 1</li>
</ul>

Note: grid-template-columns: repeat(2, 1fr); is not strictly necessary as the grid will have implicit columns based on where you tell each class to be.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Having an issue with deleting items in to do list project

How can I convert two lists into a dataframe, having one as a list of lists?

SSRS: How do I display a list of customers, from A - K then L to Z, without having two separate reports?

How do i iterate through a list having dictionaries in it,ietration must be done on the values of one key

Merge list items having more list and items

how to merge two list having dict

Android: How can I navigate from one "detail" to another "detail", while having the "Up" button go back to the "Master" list?

Split a list into multiple lists with each one having a set amount of items

how to sum the values in a list for a key in string datatype while having hyphen as one of value

How do I properly handle multiple VirtualHosts on one server with only one having SSL?

How do i test my application for network perfomance while only having a single PC?

Repeat values in a list (having two list) in python

How to merge more than one list having objects into one list with sum of one of the elements of the list in c#

How can I have my template display a list on two different div tags without having redundancies

How do I achieve having a dropdown list in an edittext? NOTE: I don't want to use spinner

How do I add items to a list? using only onsubmit <form>

How Do I Remove A Set Of Items Only Once From A List?

How do I group two items in a list of tuples as a dictionary?

How Do I Generate a List of Items Not Shared Between Two Dataframes

How to get the list of all columns having NULL values only in hive?

How can I filter a list having multiple values using jQuery and CSS?

Hibernate CriteriaQuery How to Find list of integer having two conditions

How to sort out a list having string date and time in two formats?

Two monitors when only having one in 13.10

How is a literal list having one element represented unambiguously in perl?

How can I append two list items to one item with two items inside? (Python)

How do I list the files having particular strings from group of directories in bash?

How do I list all tables in a schema having specific column in oracle sql?

How do I loop through a list of li tags having same class and change their corresponding styles