Home >Web Front-end >H5 Tutorial >How to make H5 responsive web design
This time I will show you how to make H5 responsive web design, and what are the precautions for H5 responsive web design. The following is a practical case, let's take a look.
This article introduces the implementation of HTML5 responsive (adaptive) web design and shares it with everyone. The details are as follows: Step one: Add a line of viewport meta tags to the head of the web page code.<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--[if lt IE 9]> <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script> <![endif]-->Step 2: (Note) Do not use absolute width, font size
width:auto; / width:XX%;Step 3: (Note) Font sizeThe font size is 100% of the default size of the page, that is, 16 pixelsDo not use the absolute size "PX" for the font, but use the relative size "REM"
overflow (overflow), avoiding the appearance of horizontal scroll bars
Step 5: Choose to load CSSThe core of "adaptive web design" is the Media Query module introduced by CSS3 . Automatically detect the screen width, and then load the corresponding CSS file<style type="text/css"> img{ max-width:100%;} video{ max-width:100%; height:auto;} header ul li{ float:left; list-style:none; list-style-type:none; margin-right:10px;} header select{display:none;} @media (max-width:960px){ header ul{ display:none;} header select{ display:inline-block;} } </style> <body> <header> <ul> <li><a href="#" class="active">Home</a></li> <li><a href="#">AAA</a></li> <li><a href="#">BBB</a></li> <li><a href="#">CCC</a></li> <li><a href="#">DDD</a></li> </ul> <select> <option class="selected"><a href="#">Home</a></option> <option value="/AAA">AAA</option> <option value="/BBB">BBB</option> <option value="/CCC">CCC</option> <option value="/DDD">DDD</option> </select> </header> </body>I believe you have mastered the method after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website! Related reading:
How to implement drag-and-drop function in H5
Summary of block-level tags in H5
About how to handle old versions of browsers that are not compatible with H5 and C3
The above is the detailed content of How to make H5 responsive web design. For more information, please follow other related articles on the PHP Chinese website!