search
HomeWeb Front-endH5 TutorialWhat is the difference between responsive and adaptive

Let me first give you a taste of the difference between responsiveness and adaptiveness. Please zoom in and out to try.
Adaptive experience http://m.ctrip.com/html5/

Responsive experience http://www.php.cn/

I have compiled several adaptive and responsive articles, excerpted and modified them, please enjoy:
In the beginning, web designers Fixed-width pages will be designed. In the beginning, there were not many types of computer monitor resolutions because there were few computers at that time. Even if there were changes, they would still be 800, 850, 870, 880. For example, Open Source China's web page is customized with a fixed width of 998. As for why it is 998,
Later, with the increasing number of monitors and the popularity of notebooks, problems occurred with pages using this method. So a new layout method, width-adaptive layout, emerged. The adaptive layout we usually talk about mostly refers to the width-adaptive layout.
Under this layout, two schools have emerged:
Percent width layout

Flow layout

The subject is talking about the first school, using percentages for width and text. em, now many people are starting to use rem, which is the so-called high-definition solution. The second group of layouts is represented by iGoogle (has been discontinued).
There was no word responsive layout at the beginning, but slowly a word appeared - progressive enhancement. The appearance of new words always appears together with the old words. Just like before 3G appeared, no one called their mobile phone 2G, so the terms 3G and 2G appeared together (technically, of course, 2G technology appeared first). In the same way, after the emergence of progressive enhancement, another term "graceful degradation" also appeared. You can check the meaning of
words by yourself on wiki and Google. I will only give an example here, gmail and qqmail.
The width of both of them is 100%, and they are both adaptive. However:
qqmail is the perfect embodiment of css hack. You can almost see the same mailbox using any browser. Tencent's front-end engineers use various css hack technologies to display the mailbox page for the purpose of unification user experience.
And gmail uses progressive enhancement. The more powerful your browser is, the better the effect you see and the better the user experience.
Later, Google, as everyone is familiar with it, released android, and the Internet war moved from PC to mobile phones. There is also the release of the HTML5 standard.
Although the screen of mobile phones has become smaller, it provides richer functions. Do you remember when you used Nokia to access QQ? We visited 3g.qq.com. At that time, I was using a ZTE mobile phone to access wap.qq.com. In later smartphones, I accessed m.qq.com.
Some people can’t help but ask, “Do I really need to design a web page for each mobile phone?”, “Do I really need to design different web pages for mobile phones and computers?” Of course, there are many solutions, you can take a look at css zen garden ("Css Secret Garden" is still a very good book.
The final solution winner is responsive layout.
An important reason why responsive layout is well-known is that Twitter open sourced bootstrap. Google No. Completed from pioneer to martyr.
Let’s take a more intuitive look at the difference between responsiveness and adaptiveness:

First of all, the two methods of solving problems are different.

Adaptive is to solve how to present the same web page on devices of different sizes

The screen of mobile phones is relatively small, and the width is usually less than 600 pixels; the screen of PC The screen width is generally above 1000 pixels (the current mainstream width is 1366×768), and some even reach 2000 pixels. It is not the same for the same content to show satisfactory effects on screens of different sizes. It’s easy.

The solution for many websites is to provide different web pages for different devices, such as providing a mobile version, or an iPhone/iPad version. This ensures the effect, but it is more troublesome. Several versions need to be maintained at the same time, and if a website has multiple portals (entrances), it will greatly increase the complexity of architectural design. Therefore, some people have long wondered whether it can be "one design and universally applicable." ”, allowing the same web page to automatically adapt to screens of different sizes, and automatically adjust the size of the web page content according to the screen width

But no matter what, their main content and layout have not changed .

The concept of responsiveness should cover adaptation, and cover more content.

Adaptation still exposes a problem. If the screen is too small, even if the web page can be adapted to the screen size. Adaptation, but it will feel that the content is too crowded when viewed on a small screen. Responsiveness is a concept derived to solve this problem. It can automatically recognize the screen width and make corresponding adjustments to web design, layout and display. The content may be changed. If the screen width of the following URL is larger than 1300 pixels, the 6 images will be arranged in one row

.

If the screen width is between 600 pixels and 1300 pixels, the 6 pictures are divided into two rows.

If the screen width is between 400 pixels and 600 pixels, the navigation bar moves to the head of the web page.

If the screen width is below 400 pixels, the 6 pictures will be divided into three rows.

mediaqueri.es There are more examples like this above.

Having said a lot, in fact, everyone may be more concerned about how to implement it. Let’s talk about the implementation method:

1. Allow the web page width to automatically adjust

How does “adaptive web design” work? It's not that difficult.

First, add a line of viewport meta tags at the head of the web page code.

print?
<meta name=“viewport” content=“width=device-width, initial-scale=1” />
<meta name="viewport" content="width=device-width, initial-scale=1" />

viewport is the default width and height of the web page. The above line of code means that the width of the web page is equal to the screen width by default (width=device-width), and the original scaling ratio (initial-scale=1) is 1.0 , that is, the initial size of the web page occupies 100% of the screen area.

All major browsers support this setting, including IE9. For those older browsers (mainly IE6, 7, 8), you need to use css3-mediaqueries.js.

print?
<!–[if lt IE 9]>
    <script src=“http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js”></script>
  <![endif]–>
<!--[if lt IE 9]>
    <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
  <![endif]-->

2. Use absolute width as little as possible

Since the web page will adjust the layout according to the screen width, you cannot use the layout of absolute width, nor can you use elements with absolute width. This one is very important.

Specifically, CSS code cannot specify the pixel width:

print?
width:xxx px;  
width:xxx px;

Replace it by specifying the percentage width: At the same time, you can also calculate the width with the cal of css

width: xx%;  
width: xx%;

or

print?
width:auto;  
width:auto;

3. Relative size fonts

The font cannot use absolute size (px), but can only use relative size (em) or high-definition solution (rem), rem is not limited to font size , the previous width width can also be used, instead of percentage.

print?
body {  
    font: normal 100% Helvetica, Arial, sans-serif;  
  }  
body {
    font: normal 100% Helvetica, Arial, sans-serif;
  }

The above code specifies that the font size is 100% of the default size of the page, which is 16 pixels.

print?
h1 {  
    font-size: 1.5em;   
  }  
h1 {
    font-size: 1.5em; 
  }

Then, the size of h1 is 1.5 times the default size, which is 24 pixels (24/16=1.5).

print?
small {  
  font-size: 0.875em;  
}  
  small {
    font-size: 0.875em;
  }

The size of the small element is 0.875 times the default size, which is 14 pixels (14/16=0.875).

4. Fluid grid

The meaning of "fluid grid" is that the position of each block is floating and not fixed. For more information, check out the article on fluid layouts.

print?
.main {  
    float: right;  
    width: 70%;   
  }  
  .leftBar {  
    float: left;  
    width: 25%;  
  }  
.main {
    float: right;
    width: 70%; 
  }
  .leftBar {
    float: left;
    width: 25%;
  }

The advantage of float is that if the width is too small to fit two elements, the following element will automatically scroll to the bottom of the previous element and will not overflow (overflow) in the horizontal direction, avoiding the horizontal scroll bar. 's appearance.

In addition, you must be very careful when using absolute positioning (position: absolute).

5. Choose to load CSS

The core of "adaptive web design" is the Media Query module introduced by CSS3.

What it means is to automatically detect the screen width and then load the corresponding CSS file.

print?
<link rel=“stylesheet” type=“text/css”
    media=“screen and (max-device-width: 400px)”
    href=“tinyScreen.css” />
<link rel="stylesheet" type="text/css"
    media="screen and (max-device-width: 400px)"
    href="tinyScreen.css" />


The above code means that if the screen width is less than 400 pixels (max-device-width: 400px), load the tinyScreen.css file.

print?
<link rel=“stylesheet” type=“text/css”
    media=“screen and (min-width: 400px) and (max-device-width: 600px)”
    href=“smallScreen.css” />
<link rel="stylesheet" type="text/css"
    media="screen and (min-width: 400px) and (max-device-width: 600px)"
    href="smallScreen.css" />

If the screen width is between 400 pixels and 600 pixels, load the smallScreen.css file.

In addition to loading CSS files with html tags, you can also load them in existing CSS files.

print?
@import  url(“tinyScreen.css”) screen and (max-device-width: 400px);  
 @import  url("tinyScreen.css") screen and (max-device-width: 400px);

6. CSS @media rules

In the same CSS file, you can also choose to apply different CSS rules according to different screen resolutions.

print?
@media  screen and (max-device-width: 400px) {  
    .column {  
      float: none;  
      width:auto;  
    }  
    #sidebar {  
      display:none;  
    }  
  }  
@media  screen and (max-device-width: 400px) {
    .column {
      float: none;
      width:auto;
    }
    #sidebar {
      display:none;
    }
  }

The above code means that if the screen width is less than 400 pixels, the column block will cancel floating (float:none), the width will be automatically adjusted (width:auto), and the sidebar block will not be displayed (display:none).

7. Adaptive image (fluid image)

In addition to layout and text, "adaptive web design" must also implement automatic scaling of images.

This only requires one line of CSS code:

print?
img { max-width: 100%;}  
img { max-width: 100%;}

This line of code is also valid for most videos embedded in web pages, so it can be written as:

print?
img, object { max-width: 100%;}  
img, object { max-width: 100%;}

Older versions of IE do not support max -width, so I had to write:

print?
img { width: 100%; }  
img { width: 100%; }

In addition, when scaling images on the Windows platform, image distortion may occur. At this time, you can try to use IE's proprietary command:

print?
img { -ms-interpolation-mode: bicubic; }  
img { -ms-interpolation-mode: bicubic; }

or Ethan Marcotte's imgSizer.js.

print?
addLoadEvent(function() {  
    var imgs = document.getElementById(“content”).getElementsByTagName(“img”);  
    imgSizer.collate(imgs);  
  });  
addLoadEvent(function() {
    var imgs = document.getElementById("content").getElementsByTagName("img");
    imgSizer.collate(imgs);
  });

However, if possible, it is best to load images of different resolutions according to different screen sizes. There are many ways to do this, both on the server side and on the client side.

The above is the detailed content of What is the difference between responsive and adaptive. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML5 and H5: Understanding the Common UsageHTML5 and H5: Understanding the Common UsageApr 22, 2025 am 12:01 AM

There is no difference between HTML5 and H5, which is the abbreviation of HTML5. 1.HTML5 is the fifth version of HTML, which enhances the multimedia and interactive functions of web pages. 2.H5 is often used to refer to HTML5-based mobile web pages or applications, and is suitable for various mobile devices.

HTML5: The Building Blocks of the Modern Web (H5)HTML5: The Building Blocks of the Modern Web (H5)Apr 21, 2025 am 12:05 AM

HTML5 is the latest version of the Hypertext Markup Language, standardized by W3C. HTML5 introduces new semantic tags, multimedia support and form enhancements, improving web structure, user experience and SEO effects. HTML5 introduces new semantic tags, such as, ,, etc., to make the web page structure clearer and the SEO effect better. HTML5 supports multimedia elements and no third-party plug-ins are required, improving user experience and loading speed. HTML5 enhances form functions and introduces new input types such as, etc., which improves user experience and form verification efficiency.

H5 Code: Writing Clean and Efficient HTML5H5 Code: Writing Clean and Efficient HTML5Apr 20, 2025 am 12:06 AM

How to write clean and efficient HTML5 code? The answer is to avoid common mistakes by semanticizing tags, structured code, performance optimization and avoiding common mistakes. 1. Use semantic tags such as, etc. to improve code readability and SEO effect. 2. Keep the code structured and readable, using appropriate indentation and comments. 3. Optimize performance by reducing unnecessary tags, using CDN and compressing code. 4. Avoid common mistakes, such as the tag not closed, and ensure the validity of the code.

H5: How It Enhances User Experience on the WebH5: How It Enhances User Experience on the WebApr 19, 2025 am 12:08 AM

H5 improves web user experience with multimedia support, offline storage and performance optimization. 1) Multimedia support: H5 and elements simplify development and improve user experience. 2) Offline storage: WebStorage and IndexedDB allow offline use to improve the experience. 3) Performance optimization: WebWorkers and elements optimize performance to reduce bandwidth consumption.

Deconstructing H5 Code: Tags, Elements, and AttributesDeconstructing H5 Code: Tags, Elements, and AttributesApr 18, 2025 am 12:06 AM

HTML5 code consists of tags, elements and attributes: 1. The tag defines the content type and is surrounded by angle brackets, such as. 2. Elements are composed of start tags, contents and end tags, such as contents. 3. Attributes define key-value pairs in the start tag, enhance functions, such as. These are the basic units for building web structure.

Understanding H5 Code: The Fundamentals of HTML5Understanding H5 Code: The Fundamentals of HTML5Apr 17, 2025 am 12:08 AM

HTML5 is a key technology for building modern web pages, providing many new elements and features. 1. HTML5 introduces semantic elements such as, , etc., which enhances web page structure and SEO. 2. Support multimedia elements and embed media without plug-ins. 3. Forms enhance new input types and verification properties, simplifying the verification process. 4. Offer offline and local storage functions to improve web page performance and user experience.

H5 Code: Best Practices for Web DevelopersH5 Code: Best Practices for Web DevelopersApr 16, 2025 am 12:14 AM

Best practices for H5 code include: 1. Use correct DOCTYPE declarations and character encoding; 2. Use semantic tags; 3. Reduce HTTP requests; 4. Use asynchronous loading; 5. Optimize images. These practices can improve the efficiency, maintainability and user experience of web pages.

H5: The Evolution of Web Standards and TechnologiesH5: The Evolution of Web Standards and TechnologiesApr 15, 2025 am 12:12 AM

Web standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools