Style views row layout debending on result count How to style views row layout debending on result count?

If views has 4 results then items should be placed on two rows and two columns:
| |
| |

And when views has more than 4 items - for example 6 then: 
| | |
| | |
You could implement hook_views_pre_render and count the number of results, then apply a class to the wrapper element.

function hook_views_pre_render(&amp;$view) {
  switch($view-&gt;name) {
    case 'MY_VIEW_NAME':
      switch($view-&gt;current_display) {
        case 'MY_DISPLAY_ID':

          $numResults = count($view-&gt;result);

          /*
            Do your logic with $numResults here
          */
          if ($numResults &lt;= 4) {
            $grid = 2;
          }
          else {
            $grid = 3;
          }

          $view-&gt;style_plugin-&gt;options['class'] = (isset($view-&gt;style_plugin-&gt;options['class'])) ? $view-&gt;style_plugin-&gt;options['class'] . ' grid-' . $grid : 'grid-' . $grid;

          break;
      }
      break;
  }
}


So then you can style the width of the views-row under grid-2 to be 50%, and 33% width for views-row under grid-3 in your CSS.

Your View display needs to use "HTML List" format for this code to work.