02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Thinking Fluid

A good fluid design starts with a good strategy in picking the measurement types to be used in an HTML/CSS project. In this lecture we will get to know the different CSS measurement types and then showcase a plan on how to make almost any design fluid ready. By the end of this lecture, you will have a great foundation for building advanced fluid and responsive designs.

Keynotes:

  • The CSS measurement types
  • Absolute vs. relative measurement types.
  • When to use what?

Properties:

responsive design, relative and absolute measurement types, fluid design strategy

Video Transcript

00:00Welcome to a new section and this section is all about advanced design strategies
00:05But really it's about wrapping up the topic of media queries in general and the strategies involved with responsive design
00:13So in this chapter, we're gonna talk about fluid design
00:16But really talk about great strategies to build really great fluid designs
00:21We're gonna continue on talking about working with aspect ratios, which is something very appropriate if you're designing for televisions
00:29We're also going to look at how do you optimize your work based on a device resolution?
00:34We talked about it briefly previously, but we're going to take a deeper look into it in this lecture
00:39Well in this chapter and we're gonna fun finish up with talking about
00:44designing for devices that have less colors and how do you configure and optimize to those type of devices and
00:51Last but not least we're gonna wrap up all the remaining topics
00:54So really by the end of this section, you're gonna know everything about responsive design all the core rules all the core features and capabilities
01:03So what are we gonna do in this lecture this lecture talking about?
01:08Thinking fluidly the mention of that is really talking about measurement units briefly
01:14We've seen them throughout the chapter
01:15But we're gonna dedicate this lecture to that and seeing how could we use the different measurement types available in CSS to create?
01:23Very easily very responsive and fluid designs
01:27so we're gonna look at the differences between absolute sizes and
01:31Relative sizes and we're gonna ask ourselves when should we use what and what is more appropriate and what scenario?
01:37But then to this lecture, you're really gonna know everything you need to know to start creating responsive fluid designs
01:44So let's jump right into it
01:46I'm gonna go into my browser because I really want to start and go into the section 3 source files and
01:51Click into the references link of CSS measurement types in there. You're gonna find a nice long
01:59Article talking about CSS measurement unit types
02:02I want to talk briefly about absolute measurements and absolute measurements are literally physical values
02:09Which could become very useful also on the web if you want to make sure that a design is in a specific size
02:14if it's a millimeter if it centimeters if it's
02:19Pixels if it's inches, where does this become really useful?
02:22This is really useful when it comes to fonts because if you want to make sure that your font is legible no matter
02:28What in different devices no matter how small they are you could define and say how much actual size and inches is your font?
02:35If you use a pixel size contrary to that a device that has very condensed pixels would just not portray it very well
02:44So that's really a really good place where you would want to define an absolute value and not a relative value
02:50So let's move on to the next step
02:52The case of pixels is a little bit different as we just mentioned
02:56It's still kind of absolute, but it's absolute to the screen or device itself
03:01and what I mean by that is a pixel could be in a lot of different sizes and
03:05When you grab a different monitor a different device
03:08You'll see that different monitors have different resolutions or that the user
03:12Configured a different resolution if it's on a desktop or the device itself has the features or a capability of displaying a certain amount of
03:21pixels per inch and really that's the case of pixels makes it relative because of that because you could have a computer that has a width of
03:291024 pixels, but then you could also have a cell phone with a thousand and twenty four pixels
03:34And you definitely don't want to have the same size of font on your desktop in a pixel format
03:39Like you would want on a mobile because then it would just not be legible at all on a mobile device
03:44So we talked about already about this the absolute values
03:47We talked about the almost absolute or really absolute to the monitor of the user
03:52The next one is relative or static units
03:55But really we're talking about relative units and reli- well not sorry
03:59Should use relative or static that was that headline, but we really we're talking about relative measurements now
04:05relative measurements contrary to the measurements that were absolute are
04:09relative to something else and usually they're relevant or to the font or to the screen itself or to
04:16the the character zero or to the character zero and
04:20And you read into the article to really get to know all the different measurements
04:24We're not going to do them in this lecture to save us time
04:26But please do go into this article and read it. It's going to really help you
04:30Get to understand better the different varieties of measurements and their recommendations the end of which one to use and when
04:37But when we're coming to our recommendations when you're really talking about in general
04:41We want to use relative paths on a screen on a printer
04:45usually you want to use some stuff that are basically measurements that are accurate exact and
04:50Occasionally we want to use other measurements now
04:53We're going to go ahead and go to basically start designing and start
04:58configuring so you can see that if the W 3c recommends that we use a screen usually of
05:04Percentages Ems or pixels while occasionally use EX now
05:09What is EX EX is also a relative measurement, but it's relative to the height of a specific letter
05:15Which is X alright, so not incredibly useful and not that widely supported
05:20That's why you probably don't want to use it that often
05:22but let's go ahead and start designing our design and I'm going to go into my source files and
05:27Right into the my styling and what I want to do first is I want to define an
05:32Absolute size in our body itself now this absolute size. I'm going to go to my font size
05:37I could decide that I want to set it in pixels, but like we said if I set it to be pixels
05:43It's not going to be you know. It's not going to be a size. It will be unifiably
05:47workable really in many ways because
05:51Excuse me in many ways because if I set it to be in a size that is that is defined in that way
05:56My problem would be is that on a mobile device it wouldn't work, but in my case. I really don't care about a mobile
06:03Configuration because I'm going to go ahead and make tweaks if we're going to go to smaller devices
06:08So I'm going to go ahead and not set a real absolute value because I'm going to assume
06:14that there is a monitor that has basically a
06:17Certain size and I'm going to really start off by just saying I'm going to go for pixels
06:21I could say I want to go for points as well
06:23Let's say I'm going to go to 16 points now if I set it to 16 points
06:27And I'd go ahead and I just refresh my screen
06:29I'm going to see this is the only line that has that font size and we'll see that everything grew just by a bit
06:35So they gave me a core size. I have a 16 pixel. That is my core size now that I have a sorry
06:4216 points and again those 16 points are absolute measurements
06:46So if I go here to my calculator really if I go to those absolute sizes
06:50Then once a point is 172 of an inch so really we're not talking about a massive size
06:56If we really wanted to calculate it
06:58We could just go ahead here and say
06:5916 divided by 72 and we would get the value that we're talking about 0.22 percent of an inch
07:06And that works for us that size is is decent for our work that we want to do
07:11Now the next step that I want to do is I want to go ahead in any place where I defined pixels and any place
07:17Where I define something that is absolute I want to go ahead and convert that into something that's called EMs now one em is
07:26Equivalent to whatever the current font size is in the current zone that we're in so for example in this h1 before I defined
07:34a font size
07:35The current font size was really 16 if we considered the parents
07:40So what I want to do the parent of that h1 is the bodies because it is inheriting from the body in this case if it
07:46Didn't have a font size
07:47So if I go ahead here, and I just say here
07:49I want your one em and I save it and I go back and refresh my application
07:54We'll see that my main headline now would be 16 pixels in height
07:59Now I don't want it to be 16 sorry 16 points in height now
08:03What I really want to do is I want to go and convert that into a size that is somewhat comparable
08:09To that initial design size so I might say let me give it a try and set it to be 3 em
08:15And if I go ahead here
08:16I could just set here at 3 em and obviously this is way too big find it to 2 em
08:21Which would be double at 16 points which would make it basically?
08:2524 points or I could go ahead and go back to that original plan and go to my fine
08:31font size set it to be pixels which is something that is very absolute and
08:35Then go to my font size and instead of setting it in all these
08:39Qualifiers I could go ahead and say okay. I want it to be 45 divided by 16
08:44So I want it to be this value and just set it to be this to doubt
08:48Whatever it was and I could literally do this to anything that is pixels
08:52So I could go ahead to this pixel format go again to 30 pixels divided by 16
08:58Copy the value that I come get back here and turn that into yams as well
09:03What I'm going to do next is I'm literally going to go through every single reference every single area here that has pixels or something
09:11that is absolute or
09:13Absolutish you could say and I'm going to go ahead and turn it into em
09:17So I'm going to stop talking and I'm going to do that relatively quickly and then we're going to continue our lecture
09:27Alright, so I went ahead and I changed almost everything to em. There's just one more thing
09:32I want to talk about before I really complete list
09:35Comprelate this and this is in line 23 here in our CSS where you see our height is 200 pixels
09:41And I just wanted to you double check that you guys get this so we set our font size to be 1.875
09:47So we wouldn't go to our height there if we wanted to configure our height
09:51I wouldn't go and set it to 200 divided by 16 if I would have done that and I go ahead here and just set
09:57that value
09:59Let me just go set it save it and I go and I refresh my browser browser. Notice what happens
10:05My height becomes really high now
10:08The reason is very simple because right now the new size inside of this advert area is actually the new font size that exists
10:15Or in other words, it is not 16 pixels anymore, but it's 16 times
10:201.875 in other words, it's 30 pixels
10:24So if I wanted to configure a height and I wanted to take 200
10:28I would have to divide it by 30 in other words 667
10:33So I'm gonna go ahead into my height and I'm gonna actually not put it first to make it clear that that font size
10:38Defined it and underneath the font size
10:40I'll go ahead there and set it to be 6.67 to set it to the height that I wanted it to be
10:46And if I go ahead here and I click on refresh
10:48we'll see that now our side will come back to the size that it's meant to be and
10:53I could go ahead and do the same thing for the padding remembering that now my size is 30
10:58So I would go ahead there and set my 50 divided by 30, which would give me 1.67 ish
11:03So I'm gonna go ahead here and set it to 1.67 em
11:07Now I wanted to talk about one more thing before we wrap up this lecture because we really changed everything inside here
11:13We're refreshing everything looks the same for us
11:16But it's completely different because now we control everything through this font size
11:21Now I just want to talk about one thing I did not change in my footer all the references to pixels to the specific images
11:28The reason is very simple. The reason is because this picture really is 30 pixels
11:33So I don't want to change here and put here something that is relative because this image is not relative
11:38We're not gonna have a different size image
11:40And as I'm assuming that on all the devices that the site is going to run 30 pixels would be acceptable
11:46Then I'm just gonna keep it the way it is
11:48The reason why I'm saying that is because if I go ahead and I click here and resize my element and you can see this is the
11:55Smallest that we support and even in this case our size is quite okay
11:59But notice that the spacing here isn't all that amazing when we're getting so small
12:04So we might want to put a difference in the spacing itself and make the spacing maybe somewhat more relative
12:12So that's it for this lecture
12:14We're not done with the topic not at all talking about our fluid design and we're really talking about making our site respond to itself
12:22What that means is?
12:23How do we make our site change more dynamically in a level where when we're resizing this element or we're making it bigger?
12:30This white space remains the same and it would be really great if we could do something to maybe enhance maybe the sizing
12:37Now one thing that we could intuitively do is go to our font and create different sizes and say hey, okay
12:43So I'm gonna want this font to be 17 and just by setting the font to be 17 notice what happens here. Everything resizes
12:51But we want this to happen dynamically
12:53We don't want to need to resize the font in every single point in time and that's exactly gonna be the topic of the next lecture

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!