SlideShare a Scribd company logo
Media Queries
Allow us to change the layout without changing the content
Layout differs based on screen size
Media Types
ViewPort
• Add a viewport call to get the width before the CSS
• In the header
• <meta name="viewport" content="width=device-width,initial-scale=1">
Ways to Use Media Queries
• <link> within HTML
• <link rel=“stylesheet” href=“screen-layout.css” type=“text/css” media=“screen” />
• @media within CSS
• @media screen { body {style rules;} }
3_column_layout_relative.html
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
/*Structure*/
body {
background-color: yellow;
}
/*once the screen gets to 480px, it switches to this view */
@media screen and (min-width: 480px) {
body {
background-color: lightblue;
}
}
/*once the screen gets to 800px, it switches to this view */
@media screen and (min-width: 800px) {
body {
background-color: lightgreen;
}
}
/*once the screen get over to 1200px, it switches to this view */
@media screen and (min-width: 1200px) {
body {
background-color: white;
}
}
CSS Flexbox
A Layout Alternative to Floats
Why?
• Easier to change layout to mobile
• Gives us control over appearance
Image from https://internetingishard.com/html-and-css/flexbox/
The trick?
• Boils down to two components:
• flex container
• flex items
• Nesting these components gives the flexibility
Turn an item into a flex container by adding:
.menu-container {
/* ... */
display: flex;
}
nav{
/* ... */
display: flex;
}
Nav_layout.css:
nav ul{
display: flex;
}
Layouts Part 2
Layouts Part 2
Layouts Part 2
nav ul {
display: flex;
justify-content: center;
flex-wrap: wrap;
flex-direction: column;
}
Nav_layout.css
Layouts Part 2
Layouts Part 2
flex-direction property
Nesting Elements
• Flex containers only know how to position elements that are one level
deep (i.e., their child elements).
• They don’t care one bit about what’s inside their flex items.
• Wrapping a bunch of items in an extra <div> results in a totally
different web page.
What about a bigger view?
nav_layout.css
@media screen and (min-width: 860px) {
body {
background-color: lightblue;
}
nav a{
width: 100px;
margin:10px;
}
nav a:hover{
width: 100px;
margin:10px;
}
nav ul {
flex-direction: row;
}
}
nav li:first-child{
margin-right: auto;
}
Using the figure Element
• An image can be used as a logo, a background image, a bullet for a list
item, or the basis of an image map.
• When an image is provided for informational purposes, it can be
marked with the figure element rather than a paragraph or
another block-level element.
• The figure element can also include a caption, which you mark
using the figcaption element.
Using the figure Element
• Syntax for marking a figure:
<figure>
<img src = "imagefilename" />
</figure>
• To include a caption with a figure, add:
<figcaption>caption</figcaption>
• The figcaption content appears below the image.
• The figcaption element is nested inside the figure element.
The figure Element Example
<figure>
<img src="images/balloons.jpg">
<figcaption>Fig. 1 Neuf Balloons</figcaption>
</figure>
Some CSS is already set up for figure and figcaption in gallery_layout.css
This code does not normally make changes to the HTML layout!!!
Add div around the gallery
<div class="flex-container">
…
…
…
//all figures and captions
</div>
Setting up the gallery – gallery_layout.css
Now, add a flex layout to the .flex-container
.flex-container {
display: flex;
flex-wrap: wrap;
flex-direction:row;
justify-content: space-around;
}

More Related Content

PPTX
Chapter 7: Images
Steve Guinan
 
PPTX
Chapter 23: Web Images
Steve Guinan
 
PPTX
Chapter 17: Responsive Web Design
Steve Guinan
 
PPTX
Lect-4-Responsive-Web-06032024-082044am.pptx
zainm7032
 
PPT
Going Responsive with WordPress
James Cryer
 
PPTX
An introduction to bootstrap
Mind IT Systems
 
PDF
Introduction to Responsive Web Development
Nikhil Baby
 
PPTX
Bootstrap SLIDES for web development course
dreamy678
 
Chapter 7: Images
Steve Guinan
 
Chapter 23: Web Images
Steve Guinan
 
Chapter 17: Responsive Web Design
Steve Guinan
 
Lect-4-Responsive-Web-06032024-082044am.pptx
zainm7032
 
Going Responsive with WordPress
James Cryer
 
An introduction to bootstrap
Mind IT Systems
 
Introduction to Responsive Web Development
Nikhil Baby
 
Bootstrap SLIDES for web development course
dreamy678
 

Similar to Layouts Part 2 (20)

PDF
Responsive layouts by Maqbool
Navin Agarwal
 
PPTX
Css3
Vladimir Varun
 
PPTX
Lecture 6.pptx..........................
salmannawaz6566504
 
PDF
Great Responsive-ability Web Design
Mike Wilcox
 
PDF
Responsive design: techniques and tricks to prepare your websites for the mul...
Andreas Bovens
 
PDF
New CSS Meets the Real World
Rachel Andrew
 
PPTX
Lecture 5 & 6 Advance CSS.pptx for web
ZahraWaheed9
 
PDF
Responsive Web Design e a Ubiquidade da Web
Eduardo Shiota Yasuda
 
DOCX
What is responsive web design
Steven Geffen
 
PDF
Dynamic User Interfaces for Desktop and Mobile
peychevi
 
PPTX
Bootstrap 3
McSoftsis
 
PPTX
Responsive Web Design.pptx
datapro2
 
PDF
Responsive web design
Ben MacNeill
 
PPTX
Create Responsive Website Design with Bootstrap 3
Wahyu Putra
 
PDF
Responsive Web Design tips and tricks.
GaziAhsan
 
PDF
Rwd slidedeck
Vera Kovaleva
 
PPTX
Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)
Christian Rokitta
 
PPT
CSS for basic learner
Yoeung Vibol
 
PPTX
Day of code
Evan Farr
 
Responsive layouts by Maqbool
Navin Agarwal
 
Lecture 6.pptx..........................
salmannawaz6566504
 
Great Responsive-ability Web Design
Mike Wilcox
 
Responsive design: techniques and tricks to prepare your websites for the mul...
Andreas Bovens
 
New CSS Meets the Real World
Rachel Andrew
 
Lecture 5 & 6 Advance CSS.pptx for web
ZahraWaheed9
 
Responsive Web Design e a Ubiquidade da Web
Eduardo Shiota Yasuda
 
What is responsive web design
Steven Geffen
 
Dynamic User Interfaces for Desktop and Mobile
peychevi
 
Bootstrap 3
McSoftsis
 
Responsive Web Design.pptx
datapro2
 
Responsive web design
Ben MacNeill
 
Create Responsive Website Design with Bootstrap 3
Wahyu Putra
 
Responsive Web Design tips and tricks.
GaziAhsan
 
Rwd slidedeck
Vera Kovaleva
 
Responsive Web Design & APEX Theme 25 (OGh APEX World 2014)
Christian Rokitta
 
CSS for basic learner
Yoeung Vibol
 
Day of code
Evan Farr
 
Ad

More from kjkleindorfer (10)

PPTX
Logic and Coding of Java Interfaces & Swing Applications
kjkleindorfer
 
PPTX
Week11 Inheritance class relationships in Java
kjkleindorfer
 
PPTX
Week10 packages using objects in objects
kjkleindorfer
 
PPTX
Week9 Intro to classes and objects in Java
kjkleindorfer
 
PPTX
Intro to Bootstrap
kjkleindorfer
 
PPTX
Layouts
kjkleindorfer
 
PPTX
Using PHP to submit forms
kjkleindorfer
 
PPTX
Forms Part 1
kjkleindorfer
 
PPTX
CSS Box Model
kjkleindorfer
 
PPTX
CSS Selectors and Fonts
kjkleindorfer
 
Logic and Coding of Java Interfaces & Swing Applications
kjkleindorfer
 
Week11 Inheritance class relationships in Java
kjkleindorfer
 
Week10 packages using objects in objects
kjkleindorfer
 
Week9 Intro to classes and objects in Java
kjkleindorfer
 
Intro to Bootstrap
kjkleindorfer
 
Layouts
kjkleindorfer
 
Using PHP to submit forms
kjkleindorfer
 
Forms Part 1
kjkleindorfer
 
CSS Box Model
kjkleindorfer
 
CSS Selectors and Fonts
kjkleindorfer
 
Ad

Recently uploaded (20)

PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PDF
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
How to Apply for a Job From Odoo 18 Website
Celine George
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 

Layouts Part 2

  • 1. Media Queries Allow us to change the layout without changing the content
  • 2. Layout differs based on screen size
  • 4. ViewPort • Add a viewport call to get the width before the CSS • In the header • <meta name="viewport" content="width=device-width,initial-scale=1">
  • 5. Ways to Use Media Queries • <link> within HTML • <link rel=“stylesheet” href=“screen-layout.css” type=“text/css” media=“screen” /> • @media within CSS • @media screen { body {style rules;} }
  • 7. /*Structure*/ body { background-color: yellow; } /*once the screen gets to 480px, it switches to this view */ @media screen and (min-width: 480px) { body { background-color: lightblue; } }
  • 8. /*once the screen gets to 800px, it switches to this view */ @media screen and (min-width: 800px) { body { background-color: lightgreen; } } /*once the screen get over to 1200px, it switches to this view */ @media screen and (min-width: 1200px) { body { background-color: white; } }
  • 9. CSS Flexbox A Layout Alternative to Floats
  • 10. Why? • Easier to change layout to mobile • Gives us control over appearance
  • 12. The trick? • Boils down to two components: • flex container • flex items • Nesting these components gives the flexibility
  • 13. Turn an item into a flex container by adding: .menu-container { /* ... */ display: flex; } nav{ /* ... */ display: flex; } Nav_layout.css: nav ul{ display: flex; }
  • 17. nav ul { display: flex; justify-content: center; flex-wrap: wrap; flex-direction: column; } Nav_layout.css
  • 21. Nesting Elements • Flex containers only know how to position elements that are one level deep (i.e., their child elements). • They don’t care one bit about what’s inside their flex items. • Wrapping a bunch of items in an extra <div> results in a totally different web page.
  • 22. What about a bigger view?
  • 23. nav_layout.css @media screen and (min-width: 860px) { body { background-color: lightblue; } nav a{ width: 100px; margin:10px; } nav a:hover{ width: 100px; margin:10px; } nav ul { flex-direction: row; } }
  • 25. Using the figure Element • An image can be used as a logo, a background image, a bullet for a list item, or the basis of an image map. • When an image is provided for informational purposes, it can be marked with the figure element rather than a paragraph or another block-level element. • The figure element can also include a caption, which you mark using the figcaption element.
  • 26. Using the figure Element • Syntax for marking a figure: <figure> <img src = "imagefilename" /> </figure> • To include a caption with a figure, add: <figcaption>caption</figcaption> • The figcaption content appears below the image. • The figcaption element is nested inside the figure element.
  • 28. <figure> <img src="images/balloons.jpg"> <figcaption>Fig. 1 Neuf Balloons</figcaption> </figure> Some CSS is already set up for figure and figcaption in gallery_layout.css This code does not normally make changes to the HTML layout!!!
  • 29. Add div around the gallery <div class="flex-container"> … … … //all figures and captions </div>
  • 30. Setting up the gallery – gallery_layout.css Now, add a flex layout to the .flex-container .flex-container { display: flex; flex-wrap: wrap; flex-direction:row; justify-content: space-around; }