Bootstrap 4:Responsive Web Design
上QQ阅读APP看书,第一时间看更新

How to debug different viewports at the browser

Let's see how to debug different viewports using the Google Chrome web browser. Even if you already know that you can skip this section, it is important to refresh the steps for doing that.

First of all, open the current landing page project that we will continue working with in this chapter in the Google Chrome browser. In the page, you need to select the Developer tools option. There are many ways to open this menu:

  • Right-click at any place on the page and click on the last option Element inspector
  • Go to the setting (the sandwich button at the top-right of the address bar), click on More tools, and select Developer tools
  • The shortcut to open it is Ctrl + Shift + I (cmd for OS X users)
  • F12 in Windows also works (this is an Internet Explorer legacy)

In the Developer tools, click in the mobile phone on the left of a magnifier, as shown in the following screenshot:

How to debug different viewports at the browser

It will change the display of the viewport to a certain device and you can also set a specific network usage to limit the data bandwidth. Chrome will show a message telling you that for properly visualization you may need to reload the page to get the correct rendering.

How to debug different viewports at the browser

As shown in the next screenshot, we have activated the Device mode for an iPhone 5 device. When we set this viewport, problems started appearing because we did not make the landing page with mobile-first methodology.

How to debug different viewports at the browser

The first problem is in the second row of our layout. See how Ctrl + D breaks to a new line. That is not supposed to happen.

Another problem is that we have a horizontal scroll for this device due to some unknown reason. That sucks! We will have more work than with the opposite direction that starts with the mobile page. Keep it as a lesson for not repeating the same mistake.

Now, we can debug our website in different devices with different resolutions. You may see that the mouse cursor has changed to a gray circle. Also, the click actions have changed to tap actions. With that, you can fully test the website without the physical device.

Let's first clean out the messy parts in the layout before playing some tricks with the mobile version.