All language subtitles for 058 CSS Float and Clear.en_US

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Now we're getting really really close to the end result now.

And all we need to do is start getting our Skills section laid out in a way that looks a little bit

better than this.

So the first thing to notice is that, if I switch on Pesticide, you can see that we've got the Skills

section, and inside the Skills section,

there’s two divs. And if you look in the code then you'll see exactly the same structure here.

So this div is the Skills div, which contains two further divs, which are the Skill rows. And if you prefer

to visualize this a little bit easier by seeing which is the opening tag for the div and which one is

the closing one,

you can actually head into Atom and change your preferences in your Editor section to show the indent guides.

So now you can see that you've got these lines that show you which div matches with which closing element.

Now I actually prefer this off just because I find it too cluttery.

But it all depends on how you wish to visualize it.

But the important thing is that we've got these two divs that represent two skill-rows and I want you

to make each skill-row have only 50 percent of the width of the screen.

So at the moment it's 100 percent because it's a block element.

But I want you to change that to make it only 50 percent.

So pause the video and complete the challenge.

All right so this shouldn't be too hard. If we head into our styles.css, and we go ahead and add our

skill-row, and just make sure that you check to see if you've got any typos between the way it's named

here in the class attribute and the way that you've targeted it over here.

So we wanted to change the width to 50 percent, and we can hit save and refresh, and you can see that

even though our width for the div is down 50 percent because it's no longer 100 percent,

it’s no longer centered in the middle of our web site.

So how can we fix this?

We've seen this before, and as a challenge I want you to restore this skill-row to the center of the

web page.

So pause the video and see if you can figure out how to do that.

So as we've seen before, the way that we achieve this is by setting the margin to be auto on the left

and on the right.

So let's go ahead and do that.

So we can set the margin for this skill-row to be auto.

And that just means auto on all four sides, which will center it if we refresh our web page.

Now at the moment that div is a little bit too close to the top heading and to the next div.

So how can you change the margin property so that we end up with a 100 pixel margin at the top and 100

pixel margin at the bottom,

but keeping this margin auto on the left and right?

Pause the video and see if you can complete this challenge.

All right.

So this goes back to the circle shorthand.

So if we start from the top as we always do we're going to add a 100 pixel margin at the top.

Next we come clockwise to the right which we want to keep as auto.

Next we go down to the bottom which we said again we want 100 pixels margin.

And finally we have the left which we are going to set as auto.

So the left and the right are auto, our top and the bottom are 100 pixels.

Let's hit save and let's refresh and we can see that margin now in action.

Now the next thing I want you to do is, I want this text, both the part for the Design & Development

as well as the description text, to be left aligned.

So can you figure out which property you need to change and where in order to make that happen.

So pause the video and complete the challenge.

Right. So all we need to do is to go into the skill-row and change the text-align property.

Remember we changed this previously to make the text center aligned for most of the body.

And that in itself aligned the images to be centered as well as all of our text.

But in this skill-row here, we want the text to be left aligned, so we can change that value to left

and that will override the center text-align in the body.

So now if we hit refresh, you can see the text inside the Skills section is now left aligned,

but outside of it it’s still center aligned.

Now the next thing I want to do is to make the paragraphs of the text in here a little bit more spaced

apart by changing the line height.

So can you double the line height by changing the line height property? So

pause the video and complete the challenge.

All right. So in this case we're again going to be inside the skill-row and we're changing the line-height

property to 2.

And remember in this case we don't actually have any units and we're simply specifying a scale.

Let's hit refresh.

And you can see that our text is now a lot more spaced out and much easier to read.

Now the last thing I want to do before we look into the positioning of our skill-row is we need this image

to be a lot smaller.

So go ahead and change the width of the image to 25 percent.

All right.

So in order to target the image we need to specify their class names.

So one is called code-img and one is called chilli-img.

Now this is just the classes that I've added for my own images.

You might have named these classes differently because you might have different images.

Just check what you have as your class name before you start implementing this and make sure that it

works.

So I'm going to cluster that with the other images, and the first one is called code-img, and I want

to change the width to 25 percent of its parent, and the next one is the chilli-img,

and this again is going to have a width of 25 percent.

Let's hit save and let's refresh and you can see that they are now the same size even though they weren't

before because they're now scaled down based on the width of their parent which in this case is actually

the skill-row.

So it's now a quarter the width of the skill-row, which itself is only 50 percent the width of the

entire page.

So now comes the really interesting thing.

How can I make my text wrap around my image?

So I want this skill-row to be a lot stouter,

so less in height, and I want this image to be on the left but I want my text to be on the right of the

image and wrapping around the image as necessary.

Well, this is where the topic of this lesson comes in and that is of course floating. So we can make

the image float to the left of the text and make the text wrap around it by simply changing one property.

And that is the float property.

So if we go into our code-img and we change the float property to float left and we hit save, once

we refresh you'll see that our image is now on the left of our skill-row,

and our text is now wrapping around the image in order to display both of these on the same line.

Now it looks a little bit odd having the text right up next to the image.

So can you figure out a way of having 30 pixels of space between this text and this image?

So pause the video and see if you can complete the challenge.

Now there's a couple of ways you can do this, you can think about padding or margin.

In this case in order to apply a margin to the text it would be kind of difficult because they're completely

separate at the moment.

We've got an h3 and we've got a paragraph.

Now you could add a div to wrap them together and add a left margin to that div.

But what's much easier is to simply add a margin-right to our image.

So let's head into our code and change the code-img margin-right property to 30 pixels.

And once we refresh you'll see that our image now has a bit of space between it and the text and the

text, because it's wrapping around and now it has less width to be displayed,

it’s actually taking up the full width of that div.

And this looks a lot better than previously.

Now as a challenge I want you to use the same principles of floating to make this image appear on the

right over here,

and for the text to wrap around that image and to have the same amounts of 30 pixels of space between

the image and the text.

So pause the video now and see if you can complete this challenge.

All right.

So pretty much the same principles here.

But in this case we're not floating left anymore because we want it to be on the right of the text.

So in that case we have to change the float property to right instead of left.

And that will mean that the text will wrap around the image on the left and then we just have to add

in that margin-left of 30 pixels on the image in order to get it to have the same amount of space as

we had up here.

So this is looking pretty sweet and we're getting very very close to our end result that we're looking

for.

Now sometimes when you float an element you might not want all of the text to be wrapped around it.

So for example say if we only wanted that title to wrap around this image and to be on the right of

the image then we can actually use another property to make sure that this text does not wrap and end

up at the bottom

over here, below the image, and that property is called clear.

So if I target the paragraph here. Let’s give it a class. Let’s call it, maybe, code-skill-description, and

I'm just going to copy and paste it down here.

And if I use the clear property to clear its left side then that prevents it from wrapping anything

on the left.

So let's go ahead and try that clear left.

Hit save, refresh.

You can see that that paragraph is now pushed to below the image which is floating but that heading,

that h3, is still wrapping around the image that's floated to the left.

If you think about clear as almost like the anti float then that starts to make a little bit more sense.

So we're saying that float this image to the left and all text will wrap around it on the right.

But for this paragraph we said to clear it's left which means make sure that that left margin is clear

and not wrapped around anything, then that basically prevents it from carrying out the default behavior.

Now as a challenge, can you make this paragraph appear below this image rather than wrapped around it?

Pause the video and see if you can complete this challenge.

All right. So, it's exactly the same concept here.

Now let's go ahead and just give that paragraph a class.

Let's call this chilli-skill-description.

And again I'm going to copy it,

save the file and paste it down here.

And of course remember that dot in front because it's a class.

And in this case I still need to use clear,

but I have to clear it’s right side in order to make sure it doesn't wrap around the image, because you

can see that if I tried the same thing and I cleared its left side nothing changes because it's not

wrapping anything on its left.

But if I change this to right then you'll see that it now appears below the image and it's prevented

from wrapping the image that's floated to the right.

Now I'm actually going to go ahead and clear both of these CSS rules because I actually prefer

the look that we had previously and I'm going to get rid of these classes as well.

And this is the final result that we want to keep.

Now as they say with great power comes great responsibility.

Float is one of the most commonly used and abused CSS properties.

The thing to remember is that it has a whole bunch of corner cases.

And I recommend to only use float when really really necessary and only use it for what it's meant, which

is wrapping text around a certain element, and don't use it for positioning.

Instead use what we learned about positioning like relative or absolute positioning or using the margin

and the padding for the layout and the positioning of your web site and to leave the float property only

for the cases of wrapping text.

Then you will surely get into less trouble and less problems than if you try to use a float

just as a sort of free for all layout property, which you see a lot of people mistakenly do.

So we are really really close to the end of this module and in the next section I've got a challenge

for you to look at a specification of how we want the web site to be finally laid out, and instead of

me guiding you step by step through all the little properties that you need to change,

I want you to figure out what you need to change in order to achieve the layout that I've specified.

So in the next lesson you'll see text instructions for you to complete the final big challenge and get

this web site looking beautiful.

So for all of that I will see you on the next lesson.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.