18.11.2015 Views

Beginning Drupal 8

Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015

Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 18 ■ Creating a Responsive Site<br />

specific elements for iPhone 4. In that case, adding the following media query and associated CSS entries<br />

would address the changes specific to devices with iPhone 4 or smaller screens:<br />

@media all and (max-width: 320px)<br />

Common elements that you may want to adjust are column widths, font sizes, and image sizes. Viewing<br />

the site using one of the browser responsive web design tools will help you to identify which elements need<br />

to change.<br />

Common CSS Changes to Address Responsiveness<br />

One of the first things to think about when designing a responsive website is the need to change from fixed<br />

pixel widths and point-based font sizes. For years we’ve been designing sites to be pixel perfect, but with<br />

responsive design we need to shift our thinking from exact pixels to percentages and ems. If you’re an<br />

experienced designer and CSS developer, this may be one of the hardest aspects of changing how you think<br />

about design and the CSS that enables that design. Once you’ve made the transition, the process will be<br />

relatively simple—but to begin with, we need to think about the size of elements on the page in perspective<br />

of the percentage of the display width that they are going to consume. If you stay with fixed pixel widths,<br />

the results will be that your visitors on small-screen devices will have to scroll horizontally to see the full<br />

width of your website. Check out whitehouse.gov on your smartphone as an example. It unfortunately isn’t<br />

responsive (as of early 2015) and requires that you use your finger to scroll to the right to see the full width<br />

of the site.<br />

One of the first things to examine are any elements on the page that, when viewed on a smaller screen,<br />

result in either your site shrinking down to fit within the window or requiring you to scroll right to view the<br />

full width of your page. Typical elements on a <strong>Drupal</strong> site that often require adjustment include regions,<br />

blocks, panel panes, and views. These elements are typically set to a fixed pixel width and, to become<br />

responsive, need to be set to percentage widths.<br />

To identify which CSS elements to change, using the Google Chrome Responsive Web Design Tester,<br />

simply right-click an element you wish to change and select the Inspect Element option (see Figure 18-5).<br />

199

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!