Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of responsive web design

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge about the method of responsive web design. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Step 1: Meta tag (see demo)

Most mobile browsers will zoom the HTML page to a wider width of viewport so that the content can be displayed correctly on the screen. You can use the meta tag viewport to reset this behavior. The following viewport tag tells the browser to use the device width (device-width) as the width of the viewport and disables the initial zoom. Add this meta tag to the.

Internet Explorer 8 or older browsers do not support media queries. You can use media-queries.js or respond.js to add support for media queries in IE.

Step 2 HTML structure

In this example, I have a basic page layout consisting of a header, a content container, a sidebar, and a bottom. The head has a fixed 180px height, the content container 600px is wide, and the sidebar is 300px wide.

Step 3 Media query (Media Query)

CSS3 media query is a trick for responsive design. It is the same as writing if conditions to tell the browser how to render the page for a particular viewport width.

The following rule set takes effect when the viewport width is less than or equal to 980px. Basically, I changed the width of all containers from pixel values to percentage values so that the containers became fluid.

Then for viewport whose width is less than or equal to 700px, specify # content and # sidebar as automatic widths, and remove floats, so they can be displayed as full widths.

If the width is less than or equal to 480px (mobile device screen), reset the height of # header to auto, change the font size of H2 to 24px, and hide # sidebar.

You can write as many media queries as you want. I only showed three media queries in demo. The purpose of the media query is that different layouts can be obtained by applying different CSS rules for the specified viewport width. Media queries can be in the same stylesheet or in a separate file.

The above is all the content of this article "the method of responsive web design". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 276

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report