[Drupal] How to fix the issue with theme showing non-responsive displays in mobile devices

| | 1 min read

While working on a responsive theme using Drupal an error occurred like, the theme shows a non-responsive displays in mobile devices. I solved this by adding meta tag using the function themename_preprocess_html() with following code in template.php.


function themename_preprocess_html(&$vars) {
  $viewport = array(
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'viewport',
      'content' => 'width=device-width, initial-scale=1, maximum-scale=1',
    ),
  );

  drupal_add_html_head($viewport, 'viewport');
}