Unique Classes on lists items


In order to replicate the desired behavior you can create several Views blocks and use the pager Display a specified number of items option. Then for each block change the amount and offset:

pager options

If you would do this with 3 different blocks and use offset/amounts of 0/1, 1/2 and 3/4 you should be able to stack them and have the desired result.

If you really really want to change the class per row, have a look at the great example Dynamically adding a CSS class to a view row with template.php where you can use a views preprocessor to set the right class per row.

Tags: Views / Theming / Drupal 8

Similar questions

How to add first and last classes to local task items?
I'd like to add some classes to local task items, now there is only "active" class available which is pretty not flexible, I'd like to have "first" on first item and "last" on last item. Tried theme_menu_local_tasks() and theme_menu_local_task(), neither of them work. And the post about "Add first and last classes to secondary local tasks" is proba...
how to get individual classes for each menu list items
I am theming my website and used the following code to print my main menu. Now, I need to have individual class name of each list item, so that I can call different background images using css. I would like to have class with name 'menu-497' as shown in screenshot. I couldn't figure out how this is done. Please help. Old code which used to load ind...
How to add classes to menu items in navigation twig template
I'd like to add classes to <a>-tags for menu items that have a submenu. Currently this is my code, I can only add classes to <li> elements:
Attempting to merge in an array of items into Twig classes
I have a Twig template where I'd like to merge in an array of items as classes. So far I have this code: Note that {% for item in content.field_category | children(true) %} is using Twig Tweak. In this case for example, item represents term values for each item in plain text as: and then with <section{{ attributes.addClass(classes) }}>, I'd l...
Tiered HTML lists using Views and Taxonomy?
I would like Views to output an HTML unordered list of a certain vocabulary (Taxonomy Term). This is not a problem... the problem is that the list is rendered flat, instead of showing the parent>children relationships contained in the vocabulary. How to I get Views to render this: Instead of:
Searching for a general approach for passing custom lists of node IDs as an argument to Views 3.x
I need often to exclude (or limit to) a custom list of nodes from a view. I used to enter the PHP logic directly in the php argument code text area, but this is getting difficult to mantain. I would like to store the logic in a module or template.php. What I need is a general approach for returning a list of nids (nid1+nid2+nid3...) in the php argu...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.