CS420 Week 2
CS420 Week 2
Week 2
Bilal Bin
Umar
Mobile Screen Sizes and Viewports
Mobile Screen Sizes:
o Phones and tablets have varying resolutions and pixel densities.
o Importance of designing for multiple sizes to ensure usability.
Viewport in Mobile:
o A viewport is the visible area of a webpage on a device.
o The meta viewport tag controls how a webpage scales and fits on mobile.
Example:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
o This ensures the page adjusts according to the device’s screen size.
Fixed vs Flexible Layouts
Fixed Layouts:
o Set to a specific width, often causing content to overflow or be clipped on smaller screens.
o Example of a fixed-width layout causing horizontal scrolling on mobile.
Flexible (Responsive) Layouts:
o Automatically adjust to the screen size using CSS techniques like flexbox or grid.
o Adapts layout based on available space.
Example (CSS Grid):
.container {
display: grid;
o This code automatically resizes columns based on the screen width, making it responsive.
Rescaling and Text Reflow
Rescaling:
o Content resizes according to the device’s dimensions.
o Ensures elements remain proportional across devices.
Text Reflow:
o Adjusts how text wraps and fits within the screen width.
o Improves readability on smaller devices.
Responsive Typography:
o Use units like em, rem, or vw for font sizes that scale.
o Example:
body {
}
Viewport Units and Scaling
Viewport Units:
o vw (viewport width), vh (viewport height), vmin, and vmax.
o Useful for dynamic layouts that scale with the device size.
Example:
.element {
Scaling Settings:
o Use the meta tag to set zoom properties and prevent unwanted zooming.
o Example:
<meta name="viewport" content="width=device-width, initial-scale=1,
maximum-scale=1.0, user-scalable=no">
o This restricts users from zooming the page, ideal for mobile apps.
Separate Layouts for Mobile and Desktop