HagiCode Fullstack

适配手机

Draft: this lesson is an outline and will be expanded.

Many visitors will open your site on a phone. A site that is readable on a narrow screen is called responsive, which means it adjusts its layout to the width of the screen. In this lesson you check your site at a phone width and ask the assistant to fix what is wrong. By the end the site reads comfortably on a small screen.

How to look at a phone-sized page

You do not need a phone. Make your browser window narrow by dragging its edge, until it is about as wide as a phone. Many browsers also have a view that shows a page at phone size, which the assistant can describe for your browser if you ask. A real phone is a good second check if you can reach the site from it.

What to look for

  • Text that is cut off or runs past the edge of the screen.
  • A page you can drag sideways, which means something is too wide.
  • Buttons or links that are too small to press with a finger.
  • Pictures that are too big or squashed.

What you will do

  1. Narrow the browser window and scroll through the whole page. Write down every problem you see.
  2. Ask the assistant for one fix at a time, describing the symptom in your own words, for example: At a phone width the project cards run past the right edge. Fix only that.
  3. Reload, narrow the window again and check the result.
  4. Commit in GitHub Desktop after each fix that works.
  5. Widen the window back to full size and make sure the wide layout still looks right. A fix for phones can spoil the large view.

Check yourself

  • At a narrow width no text is cut off and the page does not scroll sideways.
  • Links and buttons are large enough to press.
  • The wide layout still looks right, and each fix has its own commit.

What comes next

Go on to Fix a planted problem, where you practise finding and correcting a mistake someone else made.