text
stringlengths 1
81
| start
float64 0
10.1k
| duration
float64 0
24.9
|
---|---|---|
to control what a page actually looks
like depending on what type of page | 5,258.01 | 5.52 |
or what type of browser
we're using to view it. | 5,263.53 | 3.05 |
So I'll go ahead and open a new
file that I'll call responsive.html, | 5,266.58 | 3.76 |
because we're going to try and
build a responsive web page now. | 5,270.34 | 3.24 |
And now, I'll go ahead and
inside the body of my page | 5,273.58 | 3.21 |
just include a big heading that says
Welcome to My Web Page, for example. | 5,276.79 | 5.86 |
And just to demonstrate what you
can do now with responsive design | 5,282.65 | 3.68 |
is I could say something like,
let me add a style tag here, | 5,286.33 | 4.2 |
where I want to say that if the size
of the screen is a certain width, | 5,290.53 | 4.74 |
then I want to style
the page in one way. | 5,295.27 | 2.16 |
And if the size of the
page is a different width, | 5,297.43 | 2.5 |
then I might want to style
the page in a different way. | 5,299.93 | 2.3 |
You might imagine that
as you shrink the screen | 5,302.23 | 1.65 |
you want to move
elements around in order | 5,303.88 | 1.7 |
to rearrange them to make the
page just look a little bit nicer | 5,305.58 | 2.92 |
on a mobile screen. | 5,308.5 | 1.26 |
So we'll do a very simple example
of just changing the color depending | 5,309.76 | 4.02 |
on the size of the screen. | 5,313.78 | 1.81 |
So let me specify now in a media query. | 5,315.59 | 2.72 |
And the syntax for media
query looks like this. | 5,318.31 | 2.35 |
I'm going to use the @
symbol and say media and then | 5,320.66 | 3.17 |
specify for what type of media I
would like to apply this query. | 5,323.83 | 4.51 |
I can say something like, if
the minimum width of the page | 5,328.34 | 3.68 |
is 600 pixels, in other words,
if the width of the page | 5,332.02 | 2.91 |
is 600 pixels or anything
larger than 600 pixels, well, | 5,334.93 | 4.38 |
then go ahead and take the body and
give it a background color of red. | 5,339.31 | 7.54 |
But then I could also add
another media query and say, | 5,346.85 | 2.61 |
you know what, for this media query let
me give it a max width of 599 pixels, | 5,349.46 | 5.46 |
meaning if the size of the
screen is 599 pixels or fewer, | 5,354.92 | 4.65 |
then maybe I'd like to take the body
and give it a background color of blue, | 5,359.57 | 5.13 |
for example. | 5,364.7 | 1.76 |
So now let's take a look at what
happens when I take this page | 5,366.46 | 2.59 |
and actually open it
and see what's going on. | 5,369.05 | 2.65 |
I'll open up responsive.html. | 5,371.7 | 2.66 |
And here's what I see normally. | 5,374.36 | 1.44 |
I see a red web page, because my
screen is longer than 600 pixels wide. | 5,375.8 | 4.42 |
But notice what happens
as a shrink this web page. | 5,380.22 | 2.27 |
If I go ahead and shrink it,
looking at it on a smaller screen, | 5,382.49 | 3.6 |
eventually it turns to blue. | 5,386.09 | 2.61 |
If it's above 600 pixels
wide, it's going to be red. | 5,388.7 | 2.97 |
If it's below 600 pixels wide,
the color changes to blue. | 5,391.67 | 4.45 |
So we're able to now use these media
queries to really fine tune control | 5,396.12 | 3.56 |
how our page is going to look on
various different types of devices. | 5,399.68 | 4.23 |
If it's on a big screen, maybe you want
the elements to look a certain way. | 5,403.91 | 3.16 |
If it's a smaller screen,
maybe they'll look differently. | 5,407.07 | 2.38 |
And you don't just need to
control a background color. | 5,409.45 | 2.25 |
You can control any CSS property you
want just by using these media queries. | 5,411.7 | 4.48 |
You can say on a big screen, you want
certain amounts of spacing or padding. | 5,416.18 | 3.67 |
You can even hide elements
on smaller screens | 5,419.85 | 1.97 |
if you want to by using a particular CSS
property called the display property. | 5,421.82 | 4.44 |
That controls whether or not
an element is even visible. | 5,426.26 | 3.24 |
And ultimately put together, this can
help to make your pages a little bit | 5,429.5 | 3.48 |
more responsive. | 5,432.98 | 1.05 |
And there are a number
of different media | 5,434.03 | 1.71 |
queries that we can apply
to our page as well. | 5,435.74 | 2.1 |
We can check to see whether a mobile
device is vertical or landscape. | 5,437.84 | 3.81 |
We can check to see whether the user
is viewing the page on their computer | 5,441.65 | 3.12 |
screen or if they've tried to print
out the contents of the page as well. | 5,444.77 | 3.58 |
So there are a number
of different options | 5,448.35 | 1.75 |
that we have to really control
how a page is going to look. | 5,450.1 | 4 |
There are some other tools we have
in our toolbox as well, though, | 5,454.1 | 2.88 |
for dealing with mobile responsiveness. | 5,456.98 | 2.04 |
And one of the tools built
into the latest version of CSS | 5,459.02 | 3.06 |
is something called flexbox. | 5,462.08 | 1.97 |
And flexbox is quite helpful if we
have multiple elements that we're all | 5,464.05 | 3.88 |
trying to display on the same
page at the same time that | 5,467.93 | 3.93 |
might overflow if we're not careful
about how we do responsive design. | 5,471.86 | 3.44 |
If we're really not
careful-- let's imagine | 5,475.3 | 1.8 |
I have six elements that show
up on my computer's monitor. | 5,477.1 | 2.86 |
When you translate that
to a mobile screen, | 5,479.96 | 1.92 |
you can imagine they might all
shrink down so that they're | 5,481.88 | 2.41 |
barely visible, something like this. | 5,484.29 | 2 |
This is probably not
what we want if we're | 5,486.29 | 1.77 |
trying to design a mobile
responsive page, for example. | 5,488.06 | 3.44 |
So you might imagine, how can
we do a little bit better? | 5,491.5 | 2.98 |
Well, another thing we could
do is take these elements | 5,494.48 | 2.76 |
and go ahead and keep
them the same size, | 5,497.24 | 2.16 |
but make you have to
scroll through them. | 5,499.4 | 2.1 |
This is now slightly better. | 5,501.5 | 1.23 |
The elements that are
at least still visible. | 5,502.73 | 1.62 |
And they're large enough
on the screen, but it | 5,504.35 | 1.77 |
would be nice not to have
to scroll through them. | 5,506.12 | 2.04 |
What would be really nice is given
that we have all this extra space, | 5,508.16 | 3.18 |
I would like to be able
to wrap around elements | 5,511.34 | 2.67 |
if I don't have enough
space for them, such | 5,514.01 | 2.01 |
that if I'm translating these
six elements to a mobile screen, | 5,516.02 | 2.97 |
they translate, but I get
them in like two rows, | 5,518.99 | 2.55 |
for example, three on
the top and three below. | 5,521.54 | 2.67 |
And flexbox is an easy way to
be able to implement something | 5,524.21 | 3.27 |
like this inside of our web pages. | 5,527.48 | 2.71 |
So let's take a look at
what that might actually | 5,530.19 | 2 |
look like to add flexbox to our page. | 5,532.19 | 3.31 |
So I'll go ahead and create a
new file called flexbox.html. | 5,535.5 | 3.98 |
We'll start with the same HTML code. | 5,539.48 | 2.13 |
And now, inside of the body, I'm
going to create first a div that | 5,541.61 | 6.78 |
is going to be called the container. | 5,548.39 | 2.65 |
And we're creating a
container, because we're | 5,551.04 | 1.88 |
going to specifically say that
everything inside the container, | 5,552.92 | 3.52 |
I would like to add flexbox
to, to be able to wrap it | 5,556.44 | 2.39 |
around so that things can go onto
multiple lines if I ever need to. | 5,558.83 | 4.05 |
Subsets and Splits