PSD to HTML 4.2) Our First Media Query
Transcription of PSD to HTML 4.2) Our First Media Query
hello and welcome back to the PSD to HTML responsive
portfolio build in thislesson
we’re gonna get started by creating some media queries to help us make
our site more responsive in these media queries will determine or will allow
us to change some CSS rules for CSS property values for some of our items
once our browser reasons reaches a specific size so for example if we were to
jump into our browser here and let me go in and change this to the site 20 folders
of RD moved our files into the site 24 yrs all the changes we make in this
lesson will be saved there but we’re gonna take a look at what happens once
we get to a certain point now remember our content now is 900 pixels wide
and once we get to that 900 pixel threshold watch what happens to our content
inside our containers all of our content including our menu appear the Facebook
icon up here and all of the texts down here its own urged right up against
the edge of that container so once we get down to that point once we reach
let’s say 899 pixels I want to add a little bit of padding a little bit of left-right
patterning inside that container class remember that container classes
the class that sets the width 900 pixels or two max with them and undertake
schools so let’s let’s start by creating a simple media query that allows
us to do that so we’ll jump into our CSS and we’re gonna come down to the very
bottom even underneath the clear fix stuff will skip a few wines and will create
a new section our last section and will call it responsive to this we’ll
have our responsive styles in it so
the way this works is we’re going to create a media query using the at media keyword
and then inside parentheses were going to set a maximum width in this particular
instance so at a max width of 899 pixels we want a certain group of CSS
rules to take effect and that’s basically what we’re seeing here again when
our browser is that a maximum width of 899 pixels in other words if it’s 899 pixels
or less than we want some things to change for example we want the container
class to now have a little bit of left and right padding in it so that the
content isn’t right up against the edge of the browser so we’ll set a pattern
here to a value of 0 space 10 pixels and sometimes when I only have one
property inside a given rule upset that entire rule on one lines let’s go into
that there were nesting these rules inside the curly brackets for this at media
query so again anything inside those curly brackets is only going to take
effect if the browser is less than 900 pixels wide or if it’s 899 or fewer pixels
wide so let’s see if that works let’s save our CSS file jump into our browser
and we’ve already got our browser less than 800 I’m sorry less than
900 pixels now so let’s just refresh it and now we can see a little bit
of padding in their little bit of space in between the text and the edge of
the browser window if we bring it back up to 900 pixels the padding for that
content area goes away and that’s kind of what we’re going for a loose we have
a little problem once we get to that break point and the padding kicks in you’ll
see that the gray background behind the edges of our featured section that
green background is gone and we can see the image behind that and that’s not what
we want we want that great background there and so we can take a look
at our CSS to try to figure out why that’s happening let’s go up to that first
feature section here and here’s our feature list and I don’t really see anything
here that would particularly because in that issue so we can make some
guesses and what I’m going to try to do here is set some left and right margins
cause I think if we set some left and right margins that amounts to the
same width as the padding we added inside the container that that should take
care of it and let’s let’s see if that actually works let’s go into our media
query down here let’s get a couple lines after container but still inside the
curly brackets for the media query and 2.2 the feature my friend list class and
let’s just give it a margin of 0 space 10 pixels so and leave the top bottom
margin 80 battle set a left right margin of 10 pixels which is the same as the
left-right patterning we applied to the container so it seems that works saying
that refresh your browser and it sort of worked we can now see that gray background
but the border has now been moved in a little bit we can see some of the
picture to the left of the border so I’m also going to try something else here
and one thing we can do is just coming here right click inspect the element
and take a look at some of the different sections so if we have her over
the unordered list we can see that that section where we can see the image there
it’s got a padding their that green bar that we see is padding so the background
we’re seeing there is a result of the padding within that container
so for that feature list if we just take that packing away in my work so
inside this feature list rule here let’s go in this down to the next line and
that’s that closing early break it down a
bit and then after margin 0:10 will set our batting zero save it and refresh and
there we go that takes care of the problem ok
so now we have a green background there instead of seeing dress event image
and then gets off to a pretty good start so we saw a lot of work to do to make
this more responsive but again it gets to a pretty good start we’ve we’ve got
a basic understanding of how these media media queries excuse me you’re going
to work and hopefully as we move forward will be able to understand how to
get everything looking like we wanted to enter Photoshop file so thank you for watching
and I’ll see you in the next video
PSD to HTML 4.2) Our First Media Query
Reviewed by Tayyab Saqlain Zakki
on
00:00
Rating:
Reviewed by Tayyab Saqlain Zakki
on
00:00
Rating:

No comments: