Ch 3
Ch 3
09CE1503
1
Concept of Responsive web
design
● Responsive web design (RWD) is a web design approach aimed at creating
web pages that look and function well on a variety of devices and screen
sizes, from desktop monitors to mobile phones.
● The main goal is to ensure an optimal user experience, with easy
navigation and readability, regardless of the device being used.
Common Attributes
1. width:
● Specifies the width of the viewport.
● Can be set to a specific value (like 600px) or set to device-width to match the
screen's width in device-independent pixels.
2. height:
● Specifies the height of the viewport.
● Can be set to a specific value or to device-height.
Viewport
3. initial-scale:
● Sets the initial zoom level when the page is first loaded.
● A value of 1.0 represents no zoom.
4. minimum-scale:
● Sets the minimum zoom level that the user is allowed to zoom out to.
5. maximum-scale:
● Sets the maximum zoom level that the user is allowed to zoom in to.
6. user-scalable:
● Controls whether the user can manually zoom in and out.
● Values are yes or no.
CSS Position and Float
Properties
CSS Position Property
The position property specifies the type of positioning method used for an element.
There are five main values: static, relative, absolute, fixed, and sticky.
1. static
● This is the default value.
● Elements are positioned according to the normal document flow.
● Properties top, right, bottom, and left do not affect static positioned elements.
CSS Position and Float
Properties
2. relative
● Elements are positioned relative to their normal position.
● top, right, bottom, and left will offset the element from its normal position without
affecting the layout of surrounding elements.
CSS Position and Float
Properties
3. absolute
● Elements are positioned relative to the nearest positioned ancestor (relative,
absolute, or fixed).
● If no positioned ancestor is found, it uses the document body, and moves along
with page scrolling.
● Removed from the normal document flow.
CSS Position and Float
Properties
4. fixed
● Elements are positioned relative to the browser window, and do not move when
the page is scrolled.
● Removed from the normal document flow.
CSS Position and Float
Properties
5. sticky
● Elements are treated as relative until they cross a specified point, then they are
treated as fixed.
● Useful for sticky headers that stay at the top of the viewport when you scroll past
them.
CSS Position and Float
Properties
CSS Float Property
● The float property is used to wrap text around elements such as images, or to create
a column-based layout.
● Elements can be floated to the left or right, and they will be removed from the normal
document flow, causing subsequent elements to wrap around them.
Values
● left: The element floats to the left of its container.
● right: The element floats to the right of its container.
● none: Default value. The element does not float.
● inherit: Inherits the float value from its parent.
CSS Position and Float
Properties
Clearing Floats
● When using float, it can affect the layout of subsequent elements.
● The clear property can be used to prevent elements from wrapping around a floated
element.
Values
● left: No floating elements allowed on the left side.
● right: No floating elements allowed on the right side.
● both: No floating elements allowed on either side.
CSS Flexbox
● CSS Flexbox (Flexible Box Layout) is a layout model that provides an efficient way to
layout, align, and distribute space among items within a container, even when their
size is unknown or dynamic.
● Flexbox aims to give a container the ability to alter its items' width, height, and order
to best fill the available space.
Basic Concepts
1. Flex Container: The parent element where display: flex or display: inline-flex is
applied.
2. Flex Items: The direct children of the flex container.
CSS Grid Layouts
● CSS Grid Layout is a powerful layout system in CSS that allows you to create
complex and responsive web layouts. It is a two-dimensional system, meaning it can
handle both columns and rows, unlike Flexbox which is mainly one-dimensional.
Basic Concepts
1. Grid Container: The parent element where display: grid or display: inline-grid is
applied.
2. Grid Items: The direct children of the grid container.
CSS Grid Layouts
justify-items Aligns grid items along the row axis (start, end, center, stretch).
align-items Aligns grid items along the column axis (start, end, center, stretch).
justify-content Aligns the grid within its container along the row axis.
CSS Grid Layouts
justify-self Aligns a grid item along the row axis within its grid area.
align-self Aligns a grid item along the column axis within its grid area.