Tao of CSS
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 66 | |
Author | ||
License | CC Attribution 3.0 Germany: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/54088 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
Plone Conference 20168 / 66
4
5
6
7
8
9
10
11
12
13
15
17
18
19
22
23
24
25
26
28
30
31
32
36
43
44
46
47
48
49
50
52
53
55
56
57
60
62
63
64
65
66
00:00
Set (mathematics)Daylight saving timeMaxima and minimaScale (map)Cross-site scriptingComputer fileComputer-generated imageryDisk read-and-write headWindowBookmark (World Wide Web)View (database)Right anglePixelGreatest elementSquare numberGraph coloringCuboidInfinitySinc functionMereologyRadiusTriangleCircleDegree (graph theory)Hidden Markov modelCodeLevel (video gaming)CASE <Informatik>QuicksortType theory1 (number)Video gameWordTouchscreenMultiplication signRectangleCodeCombinational logicOvalCartesian coordinate systemMenu (computing)TrapezoidClique-widthSlide ruleCurveMathematicsGoodness of fitWater vaporData storage deviceInformationBoom (sailing)Web pageNegative numberPosition operator2 (number)Graphics tabletLetterpress printingContent (media)BitError messageElectronic mailing listAttribute grammarWeb browserSocial classTime zoneOrder (biology)Computer fontNormal (geometry)Division (mathematics)Moment (mathematics)Link (knot theory)Element (mathematics)UsabilityWeb 2.0Shape (magazine)Medical imagingSound effectGroup actionText editorSquaring the circleCross-site scriptingPoisson-KlammerUniform resource locatorScaling (geometry)SpacetimeMetropolitan area networkFile viewerSkewnessReal numberTwitterState of matterTheory of everythingPointer (computer programming)Image resolutionAbsolute valueTheory of relativityMobile WebSummierbarkeitEqualiser (mathematics)Transformation (genetics)Computer animation
Transcript: English(auto-generated)
00:04
CSS way too much. People think I'm weird, but I love it. Today I'm going to talk to you about CSS shapes, transitions, transforms. It's the fun stuff that you don't normally
00:23
get to see. Can you hear me okay back there? First I want to talk about the basic CSS shapes like circle, square, rectangle, ovals. They're the easiest to make. The background color is due to the background of inside of it, not the border of itself. Where others
00:48
are drawn, like triangles are drawn by the border. I'll show you. So if you take a circle, to make it you have equal height and width, and then you have a border radius of
01:02
50%. So you can do 100 pixels in this case, but the cheat is to do 50%, and it works every time. If you go over 50%, it doesn't have any more effect, only when you go under
01:21
50%. So this is how they make those circles for certain web pages with images. It's just the border radius on an image tag. The sum is exactly the same CSS. Next we'll
01:41
move on to square, which is pretty much the same height and width. It's the easiest shape. Everything on the web is pretty much a square, or rectangle. Where rectangles are, you know, one of them is wider or higher than the other. Oval is a combination
02:06
of circle and rectangle, where you'd use the border radius to be 50%. In this case 50% of 100 is 50, 50% of 200 is 100, but the cheat is just to do border, the trick is just to do
02:25
border radius 50%. Those are the easy ones, easy to understand ones. Next, these are all drawn, the triangles, the trapezoid, and star, which is just two triangles anyways. They're drawn using
02:46
borders. So for example, for triangle up, there's no pixel width or height. By the way, all this will be, I have working code that you guys can look at, and I'll give you
03:02
my slides as well. But as you can see, the border left and the border right are transparent, but the border bottom, the one coming up, has the color. So if you want to look at it this way, if we change the transparent to white, that's the way it looks
03:23
like. It's sort of like three triangles. Likewise, triangle down, you're going, the main part of it's in the top, facing down. So the other two are transparent, and then the top is the color. And if we want to move it to the right, all the color,
03:46
the main amount of color is on the left-hand side, and then the other two are transparent at the top and the bottom. And what would happen with the left? Anybody, anybody? Is that the same thing, except it's the left, right? The border right has the color
04:04
going towards the left, and then the top and bottom are transparent. So what happens if you want to have a triangle that's on the top left? So you, if you would
04:20
if both of these would have colors, it would look like that. But you're making the bottom one transparent, and so since it's coming top to bottom, that's the way, that's the way it looks. Does anybody have a question about that? I see some.
04:48
So you know, the blue color is the one you want, right? And so the main stuff is coming from the top down. So the border top is the blue, and then the border bottom is the white. But when you make it transparent, it looks like that. Do you have a question?
05:09
It's kind of crazy. Obviously the logical thing that would happen is not that. You would think it was like one level, then one level, but that's not how it works.
05:27
I guess you've got to think of it as a square, but I guess in a way that it comes down this way and then up that way. Right, right. It's from top to bottom, and the other one
05:52
is from bottom to top. But you could use it for really cool things. But it doesn't
06:11
work. Maybe we continue around the four corners, the right one. The blue is coming from the top again, and the left is coming from the bottom. And right, where the blue one is
06:31
whatever it starts at, so in this case the bottom is coming up, it's blue. Sorry, the thickest part, top, is coming down. Does that make sense? It gets confusing
06:44
I guess. But if we were to go from the bottom left, it's, I don't know if I could move.
07:02
So this would be the bottom, and then that would be the top. This is transparent, I mean the right. So see, it's coming from the right side. Let's find out. Let's find out. Yes, this all works in all the browsers. Lower resolution. Come on. Let me try
07:45
to move this over here for a second. Well, let me move it down. Here we go. Can you see
08:07
that? So this one is, it starts on the right with the transparent. Let's see, pointer
08:27
right. Now you have me all messed up. If I cancel that, so I switch it to the
08:59
left, then it gets really fun. I'm trying to figure out how to explain this better.
09:40
It does, but it's trial and error in this case. Yeah. Then you end up with the
09:46
four corners. I'll put more in my notes about that. Okay. So we almost drew this when I
10:01
was doing the live thing. The trapezoid ends taper in from the left and the right. So the border comes from the bottom. When I was messing with it, I put a border left end. That's almost what it ended up looking like. And you know how we had the triangle going up? We can have the triangle going down. Do you guys understand before and after?
10:29
So before and after means I'm putting some element before the div and I'm putting some element after the div that wasn't there. It doesn't work for accessibility, but it
10:40
works for BFC stars and stuff like that. So you take and you, so this is how you build the first one. Just like you build a normal star. Border bottom, it's coming up. You know,
11:01
it's that way. And then this is after. It draws it, border down, like border top. It's coming down that way. And we use positions on this. And then we move it over on top of each other with the position. Does that make sense? All right. But you
11:23
move this over negative 50 pixels. And so the more interesting stuff. The star six is relative. And then your star six after is position absolute is relative
11:44
to the star six. Right. Absolute. Right. You have to send them both. They both have to have positions. Absolute to the relative. All right. Now we have some of those basic
12:05
things we can do, these fun things. Make a talk bubble. Pacman, yin yang. So the talk bubble's pretty easy to do because we already know how to make the square with
12:22
border radius, right? You guys all know how to do that. You set a border radius of like ten. And then we make that triangle going to the left. And then we pull it over. This is the padding for the words. You know, it's a rectangle. And then the background
12:52
color is, of course, in there. Now we make the triangle over here. It's a left one. So it comes from the right hand side. Most of it's on the right hand side. And
13:02
then these two are transparent just like we did originally here. And then a position absolute. What is what? Well, you put content in there. It's empty. But if I put a word in there, a word would go inside of there. And the big reason you would use that for before
13:29
is, say you're making a print style sheet and you want to, every link, you want to put the actual URL. You grab the attribute of the URL and you put it in there inside
13:41
brackets so the print people know where the URL was. That's one of the cool things for that. So let's make a Pacman. This one uses border radius to make a circle. And then we come from the left. Let's see. The border right is transparent. So
14:25
can you guys see this okay? So if I take away border radius, it's just a square with the right side. I mean, the left, the border left, right? No, it's not showing up. I
15:00
made it all one thing. The editor made it all one thing. I'll show you the code,
15:09
which is, this is a little bit small. So the border right is the one that's transparent.
15:46
And then the other borders have colors on them. So that's how this ends up. And you just border radius it, and it's a circle, and then you have Pacman. Waka waka. Yeah,
16:08
there's the code. And then we want to go crazy and make yin yang. So this one's a little more interesting. So I tried to break it up, and this is like the first drawing
16:22
of it, and this is combined there, and I added a green so you can see things better. So you make the border, you know, your border radius of 100 percent. I don't know if you can hear me. And then, let's see, the border is 100 percent, and the border
16:45
color is a blue, but the background is white, and so it ends up looking like that, believe it or not. But yeah, the border radius is in there. This one's before and after. Before, we take and we put in the blue on the outside border with
17:04
the white on the inside, and the width being 12 pixels. And then we go halfway up with the 50 percent position absolute. We need the content thing because it won't fill in the color if there's nothing in it, so you need to put content. Empty
17:22
space. Likewise, here's the white border with the background color of blue. It's reversed, and then it ends up looking like that, which is pretty cool.
17:46
Next we're going to get into CSS transforms, which gets into skew and scale, rotate and translate. This is where the magic happens. So to make a rectangle,
18:01
you just got to skew it. So let me show you. These are the real things that you'll be able to get, which is slightly bigger. So here you have a rectangle. Here you have
18:22
the rectangle, and it's skewed. The problem with skewed, and it's really cool, you could do navigation items up top, have little folders or whatever. The problem is the words inside are skewed. So what you have to do is you have to put
18:43
a div inside of it. I put a hover to change the skew to be the opposite side. So to make this font work, no matter what, you then have to put another div inside
19:00
of it, or span, and go exact opposite the skew that's live. So the skew is 20, this is negative 20 degrees. So it straightens it back out, and then on the hover they switch. It's negative 20 and a positive 20 degrees. The only reason I can see you using
19:26
this is fancy stuff, but menuing is probably pretty cool for that to be used. So I'm just using the x-axis, and I'm going 20 degrees. And then on hover I'm switching
19:46
it to negative 20 degrees, and it just flips it back and forth. So we get into scaling. I'm going to show you the code in a second, when I hover over
20:04
these, they're going to scale 1.2 times on hover. So we're used to the higher resolution
20:29
screens these days. You have to be aware of the surroundings, because if you go too
20:41
big it will go over the top of words. But in the heart, there's the heart. All right. So let's talk about the heart, because we're going to use rotate on this
21:01
one, which is part of our growing coolness. So when you originally draw it out, it really looks like this, because we have, we set the outside and the width and height, and then we'd use a before and after, even though before and after uses the same code
21:21
after changes some. So before, I'll draw this, after draws that, and then we rotate them, and then we move them, we scale them, transform origin, and then they end up looking like a heart. Do you follow that? They're like two silos, you know with curves
21:47
and you twist them this way, and since we're on top of each other with the same color, they end up looking like a heart. It moves it, yeah. So I think this one's
22:08
top to bottom, this is right to left. Right, because it's put here, right? It overrides
22:33
that one. Right. Since this comes whatever after, and the next one is even more
22:45
crazy. Infinity. So what we do here is same thing, we have the outside box, this whole thing, and then we make two squares, and then, let's see, we position
23:09
absolute top left with 60 pixels, right, the 60 pixels. I don't know, I think I copied my code slightly off here. But then we rotated them, we rotate them 45 degrees,
23:27
and then we put border radius in there, and that turns them into circles. I can show you that. So if we take away the radius, we got square, we take out the radius
24:00
from before, we got square, we take away the rotate, we take out the rotate for both of those. So you just rotate them, and you don't have to move them in this case. Right, it just draws the box. Right. And then the other two
24:34
ones are before and after, and you just want to optimize the before and after together, and then one of them. And then, to make things even
24:45
more complicated, yin and yang. We did yin and yang. Did I discuss yin and yang? Did I discuss how you made it? Okay. Well now we're going to rotate it. So, on hover,
25:01
as soon as I put my mouse on it, it will rotate. Which looks kind of, you know, bam, there it is. So we need to do something to make that more smooth, right? It could be anything you want. I probably changed it a lot in life. It was probably a type of...
25:39
No, there wasn't anything extra there. So next we want to talk about translating things.
25:48
So we want to make our pacman eat the little pills, right? So if I had the idea, we're
26:03
going to move him, and then we're going to also close the mouth, sort of. You know, I'm just being goofy. So when you hover over him, but then, you know, he moves, so your mouse has to sort of keep up with it. If I had a little bit more time, I would
26:25
probably have made little pills and did a little kind of crazy stuff. So now we're going to talk about transitions, and this is where it gets really cool. This is where that stuff, it looks kind of janky, is more smooth. So when there's some kind of
26:49
change on your class, so I should have put hover or something on here, hover, hover, something changes. You have the CSS attribute, how much time, what style,
27:06
is it going to move? Is it linear? Is it ease out, ease in? I'll have the list of them in a second. You can separate these, like background color,
27:23
color, font, or something in commas. You can stack those up in different speeds and all that kind of stuff. And this is the all-compassing, if you put all, everything that changes before and hover, everything that changes in the CSS will change if it's allowed to. So that last part, the linear, ease out,
27:48
these are the ones you're allowed to use. If you want to get really crazy with the math, the cubic busier is your friend. I will put a link in my,
28:02
I'll show you these real quick. Let me show you, this guy did a web page, and it shows what these different things do, how the timing is on them
28:23
naturally, which is really, really cool. I'll show you why it's cool here in a second. Firebug keeps getting in my way. So here is the circle,
28:52
doing the scaling thing, I mean doing a color change thing, over a couple seconds. Here is a circle changing size,
29:11
and you hover over it, and you pick the time, and here's rotating yin yang, which is a lot smoother than the other one. I thought about it late last night,
29:21
maybe I should make the rotating yin yang go really fast, and then spin down the road. But I didn't do it, I'm sorry. Too much beer, here's Pac-Man. So what can you do that's kind of cool?
29:40
I did the Penn State meteorology site, and if you look at the three-bar navigation up there, you will see the three bars, they're individual, and they're going to reorient themselves to make an X, and then they're going to rotate themselves again
30:02
to make the hamburger navigation. Also, how fast the page opens and how natural it feels when it opens and shuts, so it does that. Boom, it comes back. This could be a useful UI and make people feel like
30:21
you put some money into your work, some time and effort. Thank you for your time. If you have any questions, let me know. This is my contact information. I will upload all the CSS and HTML files to Dropbox,
30:43
and I'll also upload my slides somewhere. Chris, will I be able to give them all my information somewhere else? Okay. Cool. And don't forget to do this. Any questions?
31:10
What was that URL for that Facebook, the FBI? That's FBI.gov. Any other questions?
31:28
The other one is MET, I think, www.met.psu. Any other questions, anybody?
31:45
You can. Please do. It's cool. I really enjoy doing it.
32:02
I wanted to do some other stuff, but it turned out that's all the time I really have. I've been doing CSS for a really, really, really long time, maybe 15 years.
32:23
On Twitter, if you look at who I follow, you might find some really cool CSS gurus like Eric Meyer or Leah. For example, in this particular case, it does use jQuery to put a class in the body,
32:44
and same with the FBI one. Mobile is activated. This part of the page is off the canvas, and then it slides over, and that slides over. Actually, it does it better than the FBI.
33:03
Yeah. CSS is really, really accepted almost everywhere. This all works on IE 10 and above. Some of the transition stuff doesn't work as well on IE 9, but you have to put in a hyphen Microsoft.
33:24
I'd have to find the thing for you, but it works on IE 9 if you do that. All the rest of these work without browser prefixes.
33:44
Yeah, just the one jQuery thing. It's a little horrible. I'm one of those people that if CSS can do it, I want to do it with CSS.
34:03
Absolutely. Those aren't done with SVG at all.
34:23
They're just drawn up with the background colors and colors of the borders. Yeah, you can do a lot of the same things with SVG. Yeah, you can maybe do a lot more with them because you're limited to the triangle.
34:45
You're limited to certain things where SVGs you have passed, and you can fill the path and have some motion and stuff like that. Could you imagine? I thought about it. It's almost there with Yin Yang.
35:00
You're already close. Maybe I will do it before the end, and I'll do the lightning talk. One more thing. No, I didn't do it. I won't be here for the sprint because Penn State plays Ohio State. I have to go back.
35:24
Unfortunately. Any other questions? Thank you all for coming.