Teacher Juan Romero Luis
Apr 10, 2024
Unit 5
bit.ly/BWD23U5
bit.ly/BWD23U5
What is responsive design?
Responsive web design is a design approach that aims to make websites look and function well on a variety of devices, including desktops, laptops, tablets, and mobile phones. It relies on flexible layouts, flexible images, and CSS media queries.
N
Source: webdesigmuseum.org.
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <!-- The content of the document... --> </body> </html>
width=device-width part sets the page width to follow the screen-width of the device, which varies.initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.N
Teacher Juan Romero Luis
Apr 11, 2024
Unit 5
bit.ly/BWD23U5
N
Do NOT use large fixed-width elements. For instance, an image displayed at a width wider than the viewport can cause horizontal scrolling. Ensure to adjust this content to fit within the viewport width.
Do NOT let the content rely on an absolute viewport width (eg. px) to render well. It is better to use relative units.
Use CSS media queries to apply different styling for small and large screens. (we’ll se that in a few classes).
8.33%16.66%25%33.33%41.66%58.33%66.66%75%83.33%91,66%100%50%<header>
(100%)
<aside>
(25%)
<main>
(75%)
ensures the padding and border of an element are included in its total width and height, rather than added on, which can often cause layout issues.
* { box-sizing: border-box; }
allows elements to be positioned horizontally next to each other, instead of stacking vertically which is the default behavior of block-level elements.
.column1 { float: left; width: 50%; } .column2 { float: right; width: 50%; }
Teacher Juan Romero Luis
Apr 17, 2024
Unit 5
bit.ly/BWD23U5
Final project submission:
Final exam:
Project presentation:
User persona missing in most of your deliverables
Some of the projects are too ambitious (functionality)
Please, do not include teacher instructions in the final deliverable
Not clear objectives
(clarify difference between objectives of the project and the actual web)
is technique used to allow the application of different style rules to different devices based on their characteristics, such as screen size, resolution, and orientation.
@media screen and (max-width: 600px) { body { background-color: lightblue; } }
@media screen and (max-width: 900px) and (min-width: 600px) { body { background-color: purple; } }
@media only screen and (orientation: landscape) { body { background-color: lightblue; } }
You can create multiple media queries for different viewport widths, which are known as breakpoints.
/* Extra small devices (phones, 600px and down) */ @media only screen and (max-width: 600px) {...} /* Small devices (portrait tablets and large phones, 600px and up) */ @media only screen and (min-width: 600px) {...} /* Medium devices (landscape tablets, 768px and up) */ @media only screen and (min-width: 768px) {...} /* Large devices (laptops/desktops, 992px and up) */ @media only screen and (min-width: 992px) {...} /* Extra large devices (large laptops and desktops, 1200px and up) */ @media only screen and (min-width: 1200px) {...}
Teacher Juan Romero Luis
Apr 18, 2024
Unit 5
bit.ly/BWD23U5
Ceating responsive images in CSS involves ensuring that your images can adjust in size to fit a variety of screen sizes.
/* The image will not scale up beyond its original size */ img { max-width: 100%; height: auto; }
/* The image will scale up to fit its container width and, thus, could scale up beyond its original size */ img { width: 100%; height: auto; }
reating responsive images in CSS involves ensuring that your images can adjust in size to fit a variety of screen sizes.
.hero { background-image: url("images/background.jpg"); background-color: #cccccc; background-position: center; background-repeat: no-repeat; background-size: cover; }
.hero { background-image: url("images/background.jpg"); background-color: #cccccc; background-position: center; background-repeat: no-repeat; background-size: cover; }
is used to set the background color of an element.
.hero { background-image: url("images/background.jpg"); background-color: #cccccc; background-position: center; background-repeat: no-repeat; background-size: cover; }
sets the initial position. Possible values are top, bottom, left, right, and center, percentages (% the top left corner is 0% [horizontal] 0% [vertical]) or absolute values (0px 0px).
.hero { background-image: url("images/background.jpg"); background-color: #cccccc; background-position: center; background-repeat: no-repeat; background-size: cover; }
controls how a background image is repeated or tiled in an element's background. Possible values are repeat, repeat-x, no-repeat, space, and round.
N
.hero { background-image: url("images/background.jpg"); background-color: #cccccc; background-position: center; background-repeat: no-repeat; background-size: cover; }
specify the size of the background images. Possible values are auto, length (50px 100px), percentage (50% 100%), cover, and contain.
N