Media Queries

4 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€43.06
List Price:  €60.30
You save:  €17.23
£37.88
List Price:  £53.04
You save:  £15.15
CA$70.02
List Price:  CA$98.03
You save:  CA$28.01
A$76.37
List Price:  A$106.92
You save:  A$30.55
S$64.89
List Price:  S$90.85
You save:  S$25.96
HK$389.26
List Price:  HK$544.99
You save:  HK$155.73
CHF 40.23
List Price:  CHF 56.33
You save:  CHF 16.09
NOK kr507.72
List Price:  NOK kr710.85
You save:  NOK kr203.12
DKK kr321.66
List Price:  DKK kr450.35
You save:  DKK kr128.69
NZ$87.49
List Price:  NZ$122.50
You save:  NZ$35
د.إ183.58
List Price:  د.إ257.03
You save:  د.إ73.45
৳6,113.75
List Price:  ৳8,559.74
You save:  ৳2,445.99
₹4,496.64
List Price:  ₹6,295.65
You save:  ₹1,799.01
RM206.55
List Price:  RM289.19
You save:  RM82.64
₦72,365.52
List Price:  ₦101,317.52
You save:  ₦28,952
₨14,086.63
List Price:  ₨19,722.41
You save:  ₨5,635.78
฿1,601.67
List Price:  ฿2,242.47
You save:  ฿640.80
₺2,120.87
List Price:  ₺2,969.39
You save:  ₺848.51
B$268.53
List Price:  B$375.97
You save:  B$107.43
R856.40
List Price:  R1,199.03
You save:  R342.62
Лв84.25
List Price:  Лв117.96
You save:  Лв33.70
₩73,443.63
List Price:  ₩102,826.96
You save:  ₩29,383.33
₪162.70
List Price:  ₪227.79
You save:  ₪65.09
₱2,932.51
List Price:  ₱4,105.75
You save:  ₱1,173.23
¥7,800.30
List Price:  ¥10,921.04
You save:  ¥3,120.74
MX$915.71
List Price:  MX$1,282.06
You save:  MX$366.35
QR183.01
List Price:  QR256.23
You save:  QR73.22
P668.27
List Price:  P935.64
You save:  P267.36
KSh6,463.70
List Price:  KSh9,049.70
You save:  KSh2,586
E£2,376.43
List Price:  E£3,327.20
You save:  E£950.76
ብር7,819.40
List Price:  ብር10,947.79
You save:  ብር3,128.38
Kz45,612.44
List Price:  Kz63,861.07
You save:  Kz18,248.62
CLP$46,475.20
List Price:  CLP$65,069
You save:  CLP$18,593.80
CN¥353.41
List Price:  CN¥494.81
You save:  CN¥141.39
RD$3,128.37
List Price:  RD$4,379.97
You save:  RD$1,251.59
DA6,515.18
List Price:  DA9,121.78
You save:  DA2,606.59
FJ$113.64
List Price:  FJ$159.10
You save:  FJ$45.46
Q383.76
List Price:  Q537.29
You save:  Q153.53
GY$10,475.41
List Price:  GY$14,666.41
You save:  GY$4,191
ISK kr6,382.72
List Price:  ISK kr8,936.32
You save:  ISK kr2,553.60
DH463.01
List Price:  DH648.25
You save:  DH185.24
L849.45
List Price:  L1,189.30
You save:  L339.85
ден2,654.05
List Price:  ден3,715.89
You save:  ден1,061.83
MOP$401.68
List Price:  MOP$562.39
You save:  MOP$160.70
N$855.30
List Price:  N$1,197.49
You save:  N$342.19
C$1,842.57
List Price:  C$2,579.75
You save:  C$737.17
रु7,172.56
List Price:  रु10,042.16
You save:  रु2,869.59
S/168.33
List Price:  S/235.68
You save:  S/67.34
K215.17
List Price:  K301.26
You save:  K86.08
SAR187.65
List Price:  SAR262.73
You save:  SAR75.07
ZK1,147.88
List Price:  ZK1,607.12
You save:  ZK459.24
L219.21
List Price:  L306.91
You save:  L87.70
Kč1,040.74
List Price:  Kč1,457.13
You save:  Kč416.38
Ft16,421.60
List Price:  Ft22,991.55
You save:  Ft6,569.95
SEK kr472.92
List Price:  SEK kr662.13
You save:  SEK kr189.20
ARS$72,549.86
List Price:  ARS$101,575.61
You save:  ARS$29,025.75
Bs347.24
List Price:  Bs486.16
You save:  Bs138.92
COP$187,671.30
List Price:  COP$262,754.84
You save:  COP$75,083.53
₡24,656.63
List Price:  ₡34,521.26
You save:  ₡9,864.62
L1,318.49
List Price:  L1,846
You save:  L527.50
₲350,000.99
List Price:  ₲490,029.39
You save:  ₲140,028.40
$U1,963.40
List Price:  $U2,748.92
You save:  $U785.51
zł182.67
List Price:  zł255.76
You save:  zł73.08
Already have an account? Log In

Transcript

Hello, in this CSS Crash Course video, we're going to be looking at media queries. So what is a media query? Well allows you to apply different CSS rules for different device types, different sort of screen type devices. So if you wanted for mobile specific CSS rule, you could do that for desktop, a different rule for printing, a different rule for different browser sizes. And that's what we're going to be focusing on is just keep it simple. There's quite different styling for different browser size.

But like I said, you can do for different device types, and I recommend checking their app going to the web schools, website. googling IQ is a great way of learning. So first of all, what we want to do is go to our dot html file. I'm going to zoom in, and what we're going to do is create a div inside here, simply say hello. We'll save that Go to my web browser refresh. That's the text we've got.

We've got an index dot CSS, what we need to do to do a media query is pretty simple. You do app media, and the sort of like device or what you're affecting. Now, in terms of like, this is the screen here. This is could be like your device, that sort of stuff. So I'm doing the check based on something to do with the screen. And the condition is Max dash width of 512 pixels.

So basically, anything up to 500 pixels dcss will apply. So if I click type in body, background, color of blue, and now the div and I'm going to change the color to white. Save that, and then we'll go back review Fresh, it seems like nothing's changed. So let's actually resize the screen. We saw the browser should say, you know what I'm gonna inspect the element and close this down as well. When we start resizing, install, resize, you can see the width in the top right, and we're getting quite close to 512.

Now, so you'll see switch any minute. There we go. As you can see switching back and forth between, well, no styling and some extra styling that we've applied. Though we can also do the same for a minimum screen. I mean, yeah, minimum screen up media screen. And, you guessed it min dash width.

And for this, I'm gonna put 768 pixels and for the body, I'm going to put background Not bad, old ground as color of red. I'm gonna put dif, I'm gonna put a color of white. I'm also gonna put text decoration of what should I put a line through upon line for save that refresh. So we've got this minimum 768 pixel styling. So if we go below 768 pixels, we've got no styling. For if we hit 512 pixels or less, we have this particular block.

That's a great way of detecting different screen sizes. So you can change the positioning on different items. Maybe on mobile, you want certain things to be smaller or bigger. Maybe you don't even want certain things to appear in the same way or at all. And you can do that using this. So that's it for this question.

Course video on media queries. If you have any questions, feel free to post them on my education platform. So now learning Dakota, UK, if you want to see the source code, there will be a link to the GitHub page along with all your source code in this series. And as usual, thanks for watching and I hope you have a great day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.