Responsive Web Design (RWD) – Responsive Web Design is about using HTML and CSS to automatically resize, hide, shrink, or enlarge, a website, to make it look good on all devices (desktops, tablets, and phones)
Adaptive Design –Adaptive web design is different from responsive design in that there isn’t one layout that always changes. Instead, there are several distinct layouts for multiple screen sizes. And the layout used depends on the screen size used.
The image above shows the responsive design of the World Wildlife Fund web site at five screen resolutions
Both page designs are flexible to adapt to sizes above or below the 768-pixel threshold. This threshold is called the breakpoint—the point at which design layouts change in responsive design schemes
The image above shows the range of sizes and the breakpoint used in the style of the World Wildlife site. The web site design adapts to larger screen sizes, expanding and adding more content and navigation as the browser widths increase
In the example above, the breakpoint is set to 768 pixels
Use CSS style rules to change the order, positioning, and other display characteristics of your page elements
Build one basic layout and then use style rules targeted to different screen sizes
Choose a breakpoint and then design for the devices above and below that point
Adapt your design for optimal viewing in each range of screen sizes
Content, not the device needs, should dictate when you choose breakpoints
You need a Media Query
A media query is composed of an optional media type and zero or more expressions that check for the conditions of particular media features. Among the media features that can be used in media queries are ' width ', ' height ', and ' color '.
THE MEDIA TYPE
THE EXPRESSION(S)
CONDITIONAL CSS
@media screen and (max-width: 480px) {
header {width: 90%;}
}
With the addition of the following style rule, the browser will detect the maximum width of the screen. If it is 480 pixels or less, the header element will have a width of 90%
@media screen and (min-width: 480px) and (max-width: 768px}
You can add multiple media features with the and keyword
You have three options for applying media queries to specify style rules
In the following three examples, the styles are applied if the device screen has a maximum width of 480 pixels
<link rel="stylesheet" media="screen and
(max-width: 480px)” href="mobiledevice.css">
The link element applies an external style sheet named mobiledevice.css if the device screen has a maximum width of 480 pixels
@import url("mobiledevice.css") screen and
(max-width: 480px);
Using an @import rule to apply an external style sheet named mobiledevice.css if the device has a screen with a maximum width of 480 pixels:
<style>
@media screen and (max-width: 480px) {
#headstruct{
background-color: #cd0000;
}
}
</style>
Using the @media rule within a <style> element
/* smaller than 1024 pixels */
@media screen and (max-width: 1024px) {
#headstruct{
background-color: #cd0000;
}
}
/* smaller than 768 pixels */
@media screen and (max-width: 768px) {
#headstruct{
background-color: #eeff22;
}
}
/* smaller than 480 pixels */
@media screen and (max-width: 480px) {
#headstruct{
background-color: #ffee00;
}
}
img{
max-width: 100%;
height: auto;
}
By specifying a percentage for your images, it allows the image to fill the space according to the percentage specified.
The CSS object-fit property is used to specify how an <img> or <video> should be resized to fit its container.
Link to W3 schools on object-fitThe <picture> tag gives web developers more flexibility in specifying image resources.
The most common use of the <picture> element will be for art direction in responsive designs. Instead of having one image that is scaled up or down based on the viewport width, multiple images can be designed to more nicely fill the browser viewport.
<picture>
<source media="(min-width: 650px)" srcset="img_pink_flowers.jpg" >
<source media="(min-width: 465px)" srcset="img_white_flower.jpg" >
<img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;" >
</picture>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
A meta viewport element gives the browser instructions on how to control the page's dimensions and scaling.
The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).
The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.