Skip to content

Instantly share code, notes, and snippets.

@joelstein
Last active December 2, 2015 16:03
Show Gist options
  • Save joelstein/d77cc18f1f204010f559 to your computer and use it in GitHub Desktop.
Save joelstein/d77cc18f1f204010f559 to your computer and use it in GitHub Desktop.
Checklist for converting existing design to responsive
/* Prevent images from expanding beyond viewport on mobile */
@media (max-width: 767px) {
img, media {
max-width: 100%;
height: auto !important;
}
}
/* Form inputs */
input, select, textarea {
max-width: 100%;
}
/* Hide Toolbar, Admin Menu, Contextual Links, and Textarea Grippies on mobile */
@media (max-width: 767px) {
#toolbar, #admin-menu, html.js .contextual-links-wrapper, .resizable-textarea .grippie {
display: none;
}
html body.toolbar, html body.admin-menu {
padding-top: 0 !important;
margin-top: 0 !important;
}
}
/* Hide Block Edit links. */
@media (max-width: 767px) {
.block-edit-link {
display: none !important;
}
}
/* Collapse Display Suite groups on mobile */
@media (max-width: 767px) {
.ds-2col > .group-left,
.ds-2col > .group-right {
float: none;
width: auto;
margin-bottom: 1em;
}
}
/* D6 calendar month */
@media (max-width: 767px) {
.calendar-calendar .month-view table {
position: relative;
}
.calendar-calendar .month-view tr td {
width: 100%;
float: left;
text-align: left;
border: none;
border-bottom: 1px solid #ccc
}
.calendar-calendar .month-view thead tr,
.calendar-calendar .month-view tr td.empty,
.calendar-calendar .month-view tr td.has-no-events {
display: none;
}
}
/* Helper classes to target mobile */
.mobile-hide {
display: none;
}
@media (min-width: 768px) {
.mobile-only {
display: none;
}
.mobile-hide {
display: block;
}
}
<head>
<!-- Respond.js for IE8 support of media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
jQuery(document).ready(function($) {
// Clone menu on mobile.
if ($(window).width() < 768) {
$('#nice-menu-1').clone().insertAfter('#nice-menu-1').attr({id: 'responsive-nav-1', class: 'nav-collapse'});
}
});
/**
* D7 - Overrides template_preprocess_html().
*/
function MYTHEME_preprocess_html(&$variables, $hook) {
// Add mobile meta tags.
drupal_add_html_head(array(
'#tag' => 'meta',
'#attributes' => array(
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1',
),
), 'steindom_viewport');
drupal_add_html_head(array(
'#tag' => 'meta',
'#attributes' => array(
'http-equiv' => 'X-UA-Compatible',
'content' => 'IE=edge',
),
), 'steindom_ie_edge');
}
/**
* D6 - Overrides template_preprocess_page().
*/
function MYTHEME_preprocess_page(&$variables) {
// Add mobile meta tags.
$variables['head'] = drupal_set_html_head('<meta name="viewport" content="width=device-width, initial-scale=1" />');
$variables['head'] = drupal_set_html_head('<meta http-equiv="X-UA-Compatible" content="IE=edge" />');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment