I'm very new to Drupal 8 theming and I'm trying to replicate a random website to practice.

I have a problem recreating this part though:

enter image description here

I have a block with the latest news articles and a block with most popular.

I wonder if I could put unique classes on each item in the list (of latest news), that way I can make the widths different and make the floats work.

Is there anyway to do this? If I'm doing this wrong and there's a better way, feel free to tell me!

  • Please have a look at What topics can I ask about here?. You cannot ask about Implementing a functionality or a layout seen in a site, for which just a description of the feature, a screenshot, or a site URL is provided. So update your question to include some relevant code or a screnshot of your view. Commented Apr 21, 2016 at 11:44
  • @Neograph734 not asking anyone to build a code from scratch. Just wondering if it is possible and where I should look for it. Commented Apr 21, 2016 at 12:00
  • 1
    I'd create separate blocks and use the pagination function. Top post should have pager offset 0, show 1. And then for the 2 post block use offset 1 show 2. And for the 4 posts use offset 3, show 4. Much easier then attempting to set a class per row. Commented Apr 21, 2016 at 12:05
  • 1
    For setting a class per row, have a look at drupal.stackexchange.com/questions/3059/… Commented Apr 21, 2016 at 12:07
  • 1
    Well, then consider an answer like "even though it may not be a complete solution for your question, you may want to consider so and so as an alternative, or something that partially helps". Commented Apr 21, 2016 at 12:41

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.