Placeholder Image

字幕列表 影片播放

  • Please remember that the complete information for the class that you are about to view is at Eli, the computer guy dot com.

  • Not only do we have our videos there, but we have part lists, diagrams, pictures and even complete code examples.

  • So if you are watching this video and you want more information, please go to Eli, the computer guy dot com.

  • Welcome back.

  • As you know, I am Eli the computer guy and in today's clients and going to be showing you how to create a basic alert animation using CSS.

  • So whenever I'm teaching you folks many times, I am taking you from the I o T.

  • Perspective again, the Internet of things perspective.

  • The idea being is that you're going to be building and creating numerous different devices in your environment and those devices they're going to be sending information back to a main server.

  • That main server will then parse the information that is sent back to it.

  • It may put that information into a database and may use that information to send out an SMS message for an alert something like that, or it may use the information that's been presented to it in order to dynamically create an HTML Web page.

  • And then your users may have that HTML Web page open as some type of monitoring system to tell them if there is a problem in their environment.

  • One of the issues you get into when you start dealing with the user experience design is that you can create things that again they give all the information that they're supposed to give.

  • But if they don't attract the attention of the end user or they don't present the information in a way that the end user understands, it can be both technically correct and absolutely worthless.

  • Oh, the exact same time, right?

  • So imagine if you have a lot of temperature sensors in your environment.

  • And so you want to make sure that if the server room goes above a surge in Tampa cure, you want to make sure your users are alerted s so that they will take some action.

  • They may turn on the air conditioner.

  • They may open the door.

  • They may simply call the V a C technician to try to solve the problem.

  • Well, let's imagine that you have a monitor, and in that man monitor you have a Web browser that's open and in that Web browser, basically have a dynamically writing HTML document that shows you information from the different temperature sensors within your environment.

  • Now again, it's dynamic.

  • So is dynamically wrote in.

  • So as the temperature king is in your environment, the numbers will change.

  • So you know, Sensor one says 80 cents or two says 90 cents or three says, you know, 75 someone and so forth.

  • Well, one way that you could create this particular monitoring screen is simply for the text itself to update.

  • And that's it, right?

  • So Sensor one is 90 degrees so you can tell your people you can say to your people if the temperature is above 90 degrees, call the H B A C technicians.

  • But think about this.

  • If you just have a white background and you just have black text, even large Black Tex and just a Sensor one and then it goes.

  • It says 89 degrees and then you know, automatically updates.

  • And then it says 91 degrees.

  • It was just black text on a white background.

  • How many people do you think are going to notice that that is change, especially if 99.999% of the time the information being presented is normal.

  • Right?

  • Every time they look at the screen, all the temperature sent, the sensor values are normal, you know, at a certain point, people just start assuming that all the temperatures are fine.

  • I look at the screen, and when I look at the screen, the temperatures are fine.

  • Therefore, I no longer look at the story.

  • So one of the things that you could dio is simply do some basic formatting tweaks of doing something, such as changing the color of the text.

  • So let's say when the temperature is below 80 degrees, the temperature text can be green.

  • When the temperature is between, let's say, 81 degrees to 90 degrees.

  • You can have a temperature change to yellow, and when it's 91 above, you can have it turned to red, right?

  • So that is a way to visually a represent you know what is what those temperatures actually mean.

  • But again, I think about it a little bit from the user experience.

  • The user perspective, if you just simply have a static screen on this monitor.

  • Even when you change the color, when somebody gets around to looking at that screen, it will be easier for for them to determine that there's a problem.

  • So it is a better way of doing it than simply black text on a white screen.

  • But it's not necessarily going to get anybody's attention, right?

  • If I'm sitting here and I'm in a Cabinet conversation and a cup of coffee with one of my co workers and that the color over here changes, probably just not gonna notice that there's a good chance people are gonna notice that.

  • So one of the things that you could do is you can create a basic animation.

  • So instead of just simply having the color change, what if you have the background behind the color?

  • Basically, we do a def yet the background behind the color and it starts doing an animation.

  • Basically, it starts flashing red, right?

  • So I'm sitting here and I'm having a conversation.

  • My co worker and out of the corner of my eye, I start seeing this flash over here.

  • Well, then I can look a crack, the server rooms overheating again, right?

  • This is one of the things that you need to be thinking about when you're thinking about the whole user experience.

  • You Why you ex design is again not simply presenting information that is technically accurate.

  • The temperature is there.

  • White background, black text.

  • Technically, technically, you're doing your job is gonna be a horrible user experience, right?

  • One things you know you're thinking about is he ain't going these extra steps to say OK, when the temperature goes above a certain level or when the sensor hits a surgeon level, I'm going to do something that then try to attract the end users by doing something visual.

  • So what I'm going to be showing you how to do today is you can use just CSS no JavaScript.

  • So we're gonna be using today is a came out, and CSS we're going to create some very, very basic animations that can really make your i o T applications really become a hell of a lot more useful with literally just a few lines of code.

  • So the warning warning Will Robinson for today is if you're a human with eyeballs, you are not going to look what?

  • Look at this demonstration.

  • Here's a trigger warning.

  • If you have eyeballs, this demonstration might send you into seizures.

  • So I feel I feel I'm doing my my legal obligation by giving that you this morning again.

  • It is very important.

  • Understand that when I do these demonstrations and I do these classes many times, I give you very ugly demonstrations because I'm trying to get the point across, please, to not simply copy and paste what I'm showing.

  • You do a little bit of modification so that you're in users Don't hate you with that.

  • Let's go with a computer and again put your eyeballs.

  • Just take your eyeballs out, put them in a closet for the demonstration and let me show you how all this works.

  • So here we are, back in my demonstration machine again, I'm using a Mac book pro.

  • And so, in order to write this code, I used text at it for this type of scripting.

  • Oh, you need is a basic ask a text editor.

  • So if you're in the Windows world, you can use note pad again.

  • The macro Deacon use text at it.

  • If you're in the Lenox world, you can use G edit nano of him whatever you want.

  • Important thing is we're gonna have to documents here.

  • We're opening up in the Web.

  • Browser has to end with dot HTM, or Daddy came out for the web browser.

  • Open up.

  • So I've called this alert dot html on then that's gonna be pointing to a style she called alert style dot CSS.

  • Now, this is the point in the demonstration where you should pluck your eyeballs out of your head and put them under your desk for about the next two minutes.

  • And if you don't do that, it is not my fault if you have an epileptic seizure after this again, my job here is to teach you what can be done.

  • Not necessarily what you should.

  • D'oh.

  • So anyways, Jessie, you get an idea of what we're gonna be coding for.

  • Let me open up the demonstration and here's here's the demonstration.

  • Ah, So basically, with this demonstration, I'm giving you four examples.

  • Uh, what we have of the top is just a basic def.

  • So this is just a basic div.

  • It is 40 pixels high.

  • It's 100% across.

  • And what it's doing is it's going from red to white every two seconds, right?

  • So for this, let's say you could put this at the top of the scream as an animation, and then underneath you could print out the information.

  • That's important.

  • So let's say you have a lot of technical information.

  • You don't necessarily animation directly behind technical information so you can have this at the top.

  • And then the technical information can simply be a black on a white background.

  • And that would be easier for your end users to read again.

  • That's the important thing here.

  • There is what is technically possible, and then what is easy for the end users to consume.

  • And so you're going to need to be thinking about that when you create your user experience.

  • Ah, the second example here is let's say we just have basic sensor s o.

  • The sensor is pulling an information.

  • The temperature goes above let's say, 91 degrees.

  • And so what I'm having here is I have that whole bar across again.

  • But in the middle of it, I'm printing out in pee at a 35 pixel size.

  • Just say 95 degrees.

  • So again, this is a way that if you have like simple information.

  • You can have the animation of behind the text, and then the context can tell you exactly what's going on.

  • Having a long bar like this, you could put a lot of different information in that bar.

  • So again, let's say you had a lot of different sensors.

  • Let's say I had, like, 10 sensors Eat one of these bars could be one sensor and then basically you can have the animation behind whatever sensor is being triggered and then it can tell you.

  • So this is the temperature.

  • This is the humidity.

  • This is the water level.

  • This is a motion to the right.

  • You can actually have a lot of information in this bar is showing you that.

  • Let's say you're dealing with a small screen or you don't need that much information.

  • Basically the same thing with the Div.

  • Only I've made it a lot smaller than something like 40 pixels by 40 pixels.

  • And then inside, I just simply put the basic number 95.

  • So again, dynamic it written.

  • Okay, it's flashing wise, that flashing.

  • Oh, because it's 95 degrees.

  • Let me figure out what's going on.

  • The final example here is what will really give you an epileptic fit is showing you that you can animate the size of text.

  • So I have.

  • I have my little computer screaming.

  • My little computer is screaming on Basically, it's a help.

  • And so what I'm doing here again that that it's being animated.

  • The text size is going from a small text size to a large deck size, and it's just completely.

  • Lupin!

  • Lupin, Lupin!

  • Looping again?

  • Here's a quote.

  • Here is a great philosophical question.

  • If a computer screams, does anybody care?

  • That's a question for you.

  • Anyways, let me minimize that, because it really does make me nauseous.

  • That's not even a joke.

  • And again, that's one thing you have to think about.

  • Like where the school user experience like that.

  • What I just showed you literally makes me nauseous.

  • So making your users nauseous is not good.

  • So when you design whatever you're designing, don't make your users wanna vomit.

  • They're not gonna want to use your system.

  • So what was?

  • The first thing that I want to do here is I want to show you the actual HTML just to show you how these these dibs and these lord boxes work and then we'll go over to the C s s s.

  • We're gonna open up with a cure.

  • We're gonna open up with a head and we're going to link to the silent sheep again.

  • Alert style dot C s s.

  • So this is if this ill she is in the same directory as your HTML document.

  • You simply put the name there.

  • If not, you put the full file path, we're gonna close the head and we're going to open up the body from there.

  • We're going to create our different examples Here s o the first example.

  • So this is the div.

  • So this is that bar going across the top Where was just read Nothing else in it, just flashing.

  • So all I did here is I simply created a div.

  • The class is alert box and then a closeted.

  • And there's nothing else in the middle.

  • So that gives us that 40 pixel by 100% across red flashing.

  • I did a break to separate.

  • The next thing that I did is I created a dip again using the exact same alert box.

  • So I'm reusing the alert box.

  • But inside the alert box.

  • I did a P tag with a class of alert text.

  • So that's that's going to be taking a CSS formatting from the class alert text.

  • And then I put the 95 degrees so and then I closed the dip.

  • So with that, basically, it's that same the same Devdas I had before.

  • But inside I put some alert tax.

  • Then we're going to go down here.

  • We're gonna break again.

  • We're gonna go Def, We're going to a class.

  • So I created class for the DIV called Alert Square.

  • So I simply modified what that dip should look like again.

  • I think it's 40 pixels by 40 pixels to make that square.

  • I then centered in the screen.

  • I did the margins.

  • It will be centered.

  • It'll be red.

  • It'll be animated in the screen.

  • I reused the alert text.

  • So then p class equals alert Text reuse that.

  • But now I'm simply pointing out 95.

  • Instead of the additional words, I closed the P.

  • I closed the div and then we do a break.

  • Then finally we go down here to pee.

  • So for a pee I created in a class of alert message so Basically, all I have to do is call this class of alert message on, then that is then going to animate help the computer screaming.

  • Um and it's just going to do that animation.

  • We're gonna close the body.

  • And then, of course, we're gonna close.

  • You came out.

  • So since have you seen the demonstration and the HTML, we then go over to see SS, and hopefully the CSS will make a little bit more sense because, basically, with CSS, we're gonna be dealing with a couple of things.

  • Here s O.

  • The first thing that we're going to be dealing with is a class like we've been dealing with classes before, So this is a class of alert box, and then basically, with the class of alert box, we have an animation that they were going to call alert.

  • So when we're dealing with animations were going to use this thing called at key frames were going to say at key frames space.

  • And then we're going to give the name of the animation.

  • Essentially, So what is the name of the animation?

  • And then we're going to point to that name in the class that we've created So basically what I've done here is again.

  • I created a width of 100%.

  • So the width goes all the way across the web browser scream.

  • I created a height of 40 pixels.

  • So before he pixels high, I initially set the background color to white.

  • So just to give it a default color, I said it toe white.

  • Then we add the animation information.

  • So here is what we say is we say animation, hyphen name and then we have to give it the name of the animation.

  • So what?

  • That's here.

  • So key frames alert.

  • So we're gonna be calling the alert animation.

  • Then we're going to say what the animation duration ISS.

  • So this is important.

  • Understand?

  • This is actually all set within this class up here, so we're gonna say two seconds.

  • So we want this to repeat every two seconds.

  • We want this to last for two seconds, I should say, And the final thing is actually the animation it oration count.

  • So if you do not put this here, the animation will run one the single time, and that's it.

  • So with the animation iteration count, you can say how many times you want the animation to run.

  • So again, this might be good from user experience.

  • Damn poi of you say I'm with this animation to run five times and then stop so that my users don't want to vomit right again.

  • I don't really care s so I'm just gonna make it infinite.

  • Just gonna keep going around and around and around.

  • Then we're gonna go down here and we're actually looking the animation.

  • So for the animation, what we do is at key frames were going to give it a name alert.

  • We're gonna open the squiggly brackets and then for this, the animation that I'm showing you there's different ways to be able to explain the key frames.

  • But we're what we're gonna do here is from too.

  • So it's going basically going to say, go from this go from this type of formatting to this type of formatting, and it's going to add all the dynamic animation in between.

  • So what I'm gonna do isn't and then open up another score.

  • Lee Brackett.

  • So this is important.

  • So normally, like when we do a class, there's one squirrely bracket than another squiggly bracket here.

  • We're gonna have this squiggly bracket in this quickly bracket.

  • That's where the key frames, that's for the animation.

  • But inside, we're going to have the squiggly brackets for where we're going from two.

  • So we do from squiggly bracket.

  • And so basically, all I'm doing here is a background hyphen color.

  • So when you go from a background color of red again, do you remember that semi colon who closes quickly bracket too, and background color of white again, semi colon closed squiggly bracket.

  • And then we close a squiggly bracket.

  • So so here.

  • And that's where, like, down here with the the the alert font, right?

  • You can change a lot of different values within CSS.

  • So down here for the animation, I'm actually changing fought size here.

  • I'm just training background color so you could change text color.

  • You could, Kate Background color.

  • You can't fault for some reason, basically almost.

  • I have to say almost all the time almost all the CSS settings you can modify here, so it'll go from one to the other on.

  • Then we're gonna close that out.

  • So, basically again, how this works is you have the alert box.

  • It's the alert box.

  • The is going to call the minute animation of alert.

  • It's gonna have a two second duration and it's going to be an infinite account.

  • Then we're going to go down here to the alert square.

  • So basically, with the alert square, I'm going to reuse that alert animation.

  • But the difference is, is I'm changing.

  • What that did will look like.

  • So with the alert square, the width is going to be 40 pixels.

  • So instead of the with being 100% is simply going to be 40 pixels.

  • The height is going to be 40 pixels.

  • The with the with the margins with the margin hyphen left in the margin hyphen right at auto.

  • Basically, what that is going to do is that is then going to center this within the middle of the screen.

  • So basically, this is almost the same as the original Lord box on Lee.

  • I'm going to make the with smaller and I'm going to center.

  • Passed that background colors white animation.

  • Name is alert.

  • Animation is two seconds.

  • Animation generation is infinite.

  • Then we're going to go down for the alert message.

  • So with the alert message, this is going to be for that for the text that goes from small to big.

  • So here all I'm going to say is the animation name is going to be alert Font.

  • So that's going to call this animation down here again, Animation.

  • Two seconds, It oration count infinite.

  • So we go down here, I'm gonna go from fought size 40 pixels to font size 200 pixels.

  • Right, So that's what's going to happen.

  • So it's going to go from the small font to the large font.

  • Finally, down here I have the alert text that is for the text that's in in that second div when it's flashing red on and basically we're going to align it to center and we're going to make it 35 pixels.

  • So when we go over and we take a look at the at the dibs over here, basically we take a look at the HTML.

  • What we can see here is this DIV Class is calling the alert box class.

  • So we take a look at the alert box.

  • Basically, all this gets brought in that has the animation name of alert.

  • So this is brought in.

  • So that's this whole thing, is what is going to show up here with with that protection particular def.

  • We go down here to give class equals alert box.

  • Um, we're going 1/2 years again.

  • The alert box again.

  • Same animation and all that.

  • But then we do The P class equals alert text.

  • Then we're going to be using this.

  • This alert text down here that's going to be aligning the text to the center is gonna be 35 pixels.

  • Then we have the div.

  • Class equals alert square.

  • So this is the alert square class we created again.

  • 40 pixels by 40 pixels on it, centered in the middle.

  • Everything else is the same.

  • It calls the animation for alerts.

  • The background will go from red to white.

  • We're gonna have a P class equals alert text.

  • So the P is going to be that same.

  • We're gonna reuse that alert text.

  • It's gonna be centered.

  • It's gonna be 35 pixels.

  • Then finally, we're going to go down.

  • We're gonna create that alert.

  • That alert message that help, basically Help!

  • Help!

  • Help!

  • Help!

  • Soapy class equals alert.

  • Message if we take a look here.

  • So alert Message.

  • Animation Name is alert.

  • Fought So this is what it is.

  • Duration is two seconds.

  • Count is infinite.

  • It's going go from 40 pixels to hunt to 200 pixels.

  • So we take a look here.

  • Basically, what that's going to say is this is going to go from 40 pixels to 200 pixels.

  • It's gonna take two seconds to do that.

  • And then it's going to generate infinitely, basically.

  • And so that's how this animation works again.

  • If we can go here, you do things like change the animation duration.

  • So let's see if I can do animation duration 25 s o B.

  • Five seconds.

  • I could file.

  • I could do save.

  • I can bring up my REB Web browser.

  • Then I can basically refresh.

  • And now we can see that this is this is much slower and see, like the help down here.

  • See how this is taking two seconds.

  • And now with the animations up here, this is being much slower.

  • So that's now taking five seconds.

  • So again, that's the type of thing to be thinking about is how fast do you want the animation to repeat?

  • Someone is so forth, so that gives you a basic example of how to do CSS animations for things like alert boxes on again.

  • This could be very, very, very, very useful if if you don't make it so that your users wanna vomit.

  • So there you go.

  • Now you know how to use CSS to make visual alerts so that your end users pay attention to whatever problem you're trying to tell them about again.

  • It might be a temperature sensor.

  • It might be a water censor.

  • It might be a motion sensor, any kind of sensor, any kind of reading that could get pulled into your server.

  • Your server can parse that.

  • Determine what it should d'oh.

  • And then it can print something out again, dynamically into an HTML document.

  • They can print that out again, using PHP, python, ruby, whatever, you're back in languages.

  • This is the type of thing that could be very, very valuable again in an I.

  • O.

  • T.

  • Environment, where you have a screen again like, let's say, on that screen, you have 10 different sensors.

  • And so if those 10 different sensors, frankly, 99.9999999% of the time, they have the correct readings, right?

  • If you have sensors that 99.99% of the time give the correct reading.

  • What's gonna happen with end users at the end of the day is they're going to start ignoring that screen.

  • That screen is gonna be there, and they're just gonna stop looking right.

  • Because every time they look at that screen, all the sensors have the right readings.

  • So at some point, they're gonna start assuming that the sensors air right.

  • Well, again, if you have the sensors, the reason you have those sensors is because maybe something will go wrong.

  • And so if you just simply change the text again White background on black text if you just simply can't you text People aren't going to notice that if you can get the color right again.

  • He came to font color.

  • Now to be clear, when somebody actually looks at the screen, then they're more likely to notice it.

  • And because of that color, that will be more likely to understand what they should do about the information.

  • But again, when you're dealing with an end user, that requires for somebody to actually look at the screen and care care, you know may or may not happen.

  • So if you have a basic animation like idea showed you, that's a way I'm sitting here having a cup of coffee with one of my peers and all of a sudden out of the corner of my eye, I start seeing this flashing thing that that attracts my attention.

  • I take a look at it.

  • It's annoying the hell out of me.

  • So hopefully I'll go and try to fix the problem versus, you know, turn it off the screen.

  • They are users our end users, if you can, if you can, a poxy the power button that might not be the workers think lower again again when you're dealing with users.

  • When you're dealing with users, their definition of solving a problem and your definition of solving a problem might be two entirely different things.

  • What?

  • Why is the screen off?

  • Oh, because because it was flashing at me and it was annoying the hell out of me.

  • But But that means you should have gone and checked the sensor and fix the H V A C system.

  • Ah, I guess I could have done that kiss.

  • Turn off.

  • Oh, users.

  • You know some people.

  • Some people ask me Eli, Eli, if you're so good at technology, why are you doing YouTube videos?

  • Instead of being out in the field users, It was just a certain It's just that certain point, like one day you walk in and like a user is dealing doing what a user does, and you're just kind of like, You know what?

  • I'm done.

  • I go teach the next generation on how to deal with this crap.

  • I just can't deal with this crap anymore.

  • So anyways, some real world stories, But, you know, think about this again.

  • A little bit of code gives you some animation really can make your your panel's.

  • Basically you're alert boxes and all that kind of stuff, actually far more valuable to the end user and doesn't take a lot just again.

  • When you're when you're doing it, really think about how you're coding it, because again you want your end users to notice there's a problem.

  • Yeah, well is now that you don't want them to vomit.

  • Let's be honest.

  • It's not that you don't want them to vomit but vomiting in users.

  • It's probably not the best result.

  • So again think about what you're doing.

  • As always, I enjoy doing this video and look for to seeing the next one.

  • If you like the content that I create, please think about going to align the computer guy dot com and becoming a member or donating.

  • Please understand that all the educational videos are in front of the pay wall that includes the videos that includes the notes, the diagrams and the code.

  • Example.

  • All of that is freely available and in front of the pay wall.

  • But if you want to watch opinion videos, or if you want to be able to comment, you do need to become a member.

  • Membership is $5 a month or $60 a year and gives you access to those opinion videos and the ability to comment.

  • If you don't want to become a member, you just want to give a one time donation.

  • There is also a donate button where you can do that.

  • Please understand.

  • In order to provide the education that I am, it does cost money servers, cost money, equipment, costs, money, travel costs, money.

  • All of these things cost a reasonable amount of money and the fact of the matter is, is YouTube's advertising program no longer supports creators the way that it used to.

  • So if you want to these classes to continue to stick around and you find them to be valuable, please think about either becoming a monthly member or donating a few dollars for this project.

Please remember that the complete information for the class that you are about to view is at Eli, the computer guy dot com.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

CSS和HTML 5 - 警報的基本動畫演示 (CSS and HTML 5 - Basic Animation for Alerts)

  • 12 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字