CSC264 CSS-Responsive - RP
CSC264 CSS-Responsive - RP
CSC264 CSS-Responsive - RP
Desktop Phone
Responsive Web Design
Responsive web design makes your web page look good
on all devices.
Responsive web design uses only HTML and CSS.
Responsive web design is not a program or a JavaScript.
It is called responsive web design when you use CSS and
HTML to resize, hide, shrink, enlarge, or move the content
to make it look good on any screen.
Throught the slides, if the CSS property is preceded with
a period (.), it denotes that the property is a class
The Viewport
The viewport is the user's visible area of a web page.
The viewport varies with the device, and will be smaller
on a mobile phone than on a computer screen.
Before tablets and mobile phones, web pages were
designed only for computer screens, and it was common
for web pages to have a static design and a fixed size.
Then, when we started surfing the internet using tablets
and mobile phones, fixed size web pages were too large
to fit the viewport. To fix this, browsers on those devices
scaled down the entire web page to fit the screen.
Setting the Viewport
HTML5 introduced a method to let web designers take control
over the viewport, through the <meta> tag.
<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.
Effects of Viewport
Without the viewport meta tag With the viewport meta tag
Form Elements
Method Tag
Textbox <input type= "text">
Radio Button <input type= "radio">
Check Box <input type= "checkbox">
Hidden <input type= "hidden">
Text area <textarea>..</textarea>
List down box <select>..</select>
Password <input type= "password">
When any text is written in this type of input box, ‘*’ will
appear.
What is a Grid-View?
Desktop Phone
Media Query : Breakpoint
Always start with smaller size first
p {
font-size: 0.875em; /* 14px/16=0.875em */
}
Variable Font Size
Font sizes may be set to display accordingly depending on
the screen size
/* If the screen size is 601px or more, set the font-size of <div> to 80px */
@media only screen and (min-width: 601px) {
div.example {
font-size: 80px;
}
}
/* If the screen size is 600px or less, set the font-size of <div> to 30px */
@media only screen and (max-width: 600px) {
div.example {
font-size: 30px;
}
}
Images : Using The width Property
If the width property is set to a percentage and the
height is set to "auto", the image will be responsive and
scale up and down: img {
width: 100%;
height: auto;
}