Viewers: in countries Watching now:
The first step towards enhancing the user experience of our ecommerce catalog is to add in a form element new to HTML5, the range input type. It's a very straightforward tag with just a few attributes. In this lesson I'll also add in another form element, a basic text input type, so we can eventually display the actual range value as the slider moves. Finally, I'll show you a very cool CSS property that you don't want to implement to help with your slider stylings.
Next, we'll enter in the type for this input tag, and the type is going to be of course range. We want to enter in a number of different attributes now. Let's put in our minimum first. And I'm going to set the min to 50. We don't want to make our artwork too cheap. And we also made a maximum. So max, and let's make that 400 or too expensive. This is a school after all. Next, I'm going to put in an optional argument, step, so we can change how the range increments, and let's put in a step value of 25.
Finally, we want to put in our starting point, and that's handled through the value attribute. In some situations, as in the example I gave in an earlier chapter, you might want it to start right dead center, but in this situation, since what we're going to be doing is filtering out less expensive items, we want to show all of the items to start with. So we're going to place this value at its maximum, the upper limit, 400. Okay, let's close off the input tag. Now that's it for the slider, but as you saw in the previous chapter, there is an issue with the implementation of the slider where there is no real way to show what the range value is.
So I'm going to save it. Let's head back to the browser for a second, refresh the page, and there is our basic slider and the accompanying text field. Let's bring in some styles to spice it up a bit. I already have the styles created, so all we need to do is to link them in. I am going to move up to the head section of the page, and we'll put this right after our link to the main.css file. So it's link href=, and we'll copy the path, CSS main. As you can see, the code hints begin to come up, so let's take advantage of that and we're going to go to range.css, and it's also going to be rel=stylesheet and we'll use the same media tags: screen and projection.
Okay, we close that tag, and I'll save the file. Now let me open up that particular CSS file, and you can see it has two rules in it: one that targets the input with a type of range and then the other one that goes a little bit further. That's actually targeting the thumb control that moves the sliders. Now most of the properties that you see here, from the second one in each entry on down, are pretty normal, and there is no reason to spend any time on them.
However, the very first entry in both rules, -webkit-appearance, deserves a little bit of explanation. This property allows you to specify a uniform look and feel for all your widgets. However, because we want a custom one, we actually need to set it to none. So let's go over to the browser and take a look. I'll refresh the page, and there is our revised browser. It's pretty, but if you move the control, you see that pretty is all it is.
However, we've got all of our basic elements in place to bring in the very first piece of functionality.
There are currently no FAQs about HTML5 Projects: Engaging Ecommerce.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.