Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this lesson we are going to keep the focus on one specific widget, the Search widget. If we take a look at what we have now in index.php, we have a label Search for an input field, that's plain and white, and a Search button that needs some styling love. Now let's compare it to what we have in the blog_comp. Well, there's no label, the title is actually acting as a label, the input field is much larger, there is a different background color, and there is what is known as placeholder text, an HTML5 attribute by the way, and the phrase Enter keyword that you see in the center of the input text.
But also notice what you don't see. There's no Submit button of any kind. Now I purposely included this in the lesson, because this is a situation I've encountered before where there might be something in the design that's not quite right. Rather than slavishly copy the comp when you know something should be there that's not, you often need to move ahead and put in the missing element. So what we are going to do is to bring in an image that will use as the background for our Submit button.
Let's go get that now and put it in place before we start with the coding in Dreamweaver. And there is the search.png button I was talking about. Let's copy that, and now I'm going to go down to my blog folder and drill down into content > themes > roux themes > images and then paste that there. So let's head back to Dreamweaver now, and let's use Inspect mode to locate the CSS rules for the Search field. So we are in Live view.
I will turn on Inspect and just hover right over that, and we are going right to it, because this is a very specific thing. So once we have it I will click once to disable Inspect mode and then right-click on my rule and choose Go to Code. So it look like have a couple of rules here. The first rule works for all input types, input type text, email, and search as well as text areas, and that sets up some of the rules. Then there's another one that's a specific for search.
So let's copy both of these and then head on over to index.php, and we will open up our Roux stylesheet and paste those in. Now I'm probably going to have to change the selectors somewhat. But you might have to do a little digging to find out exactly what it is that you want to change and select. I know that I don't need the text area and select elements here, so I can get rid of those, but for the rest of we are going to need to go into Live Code in order to locate exactly what it is we are looking for.
So I am going to click on Live Code and then scroll over in the Design view a little bit and just click right into the Input field. That will show us the generated output that WordPress puts together and what I immediately see is that this input, which has a type of text and not a search. And that's because WordPress has not upgraded to HTML5 form elements yet. So you won't see type = search or type = email. You will see type = text most of the time.
The identifier is the id = S, and that's used on any search field that you find in WordPress. So we are going to change our selector to a id of S. Let's turn off Live Code and go to our stylesheet. So I am going to make all of these inputs, and let's just bring these properties up, because that's specific for the search, get rid of this unnecessary rule now, and it looks like I have a couple of ones that are conflicting here.
So let's get rid of the width from the more generic input styling and everything else we can leave. So I'll hit Refresh here and see how things are looking. Well, things are looking pretty good. So the next thing I am going to do is create a CSS rule for the Search form button that we'll add, and because I want to target this particular search area and not in the other general search fields, I'm going to, again, use Live Code.
Click into this area and see what the name of the form is. Here it has an id of search form. Perfect. That will help us target this exactly. So let's turn off Live Code, go back to style.css, enter in that id, and then we want to target the input button with a type = submit. So that's an attribute selector that we can add in there.
And let's add in our opening curly braces and start styling. The first thing that I want to do is bring in that search.png background image. So we'll enter in the background property, and we are looking for a URL, and that's in my _images folder, and it's called search.png. Now this image should not repeat. So we put in a no-repeat options there, and we just want to center it in its area.
So I am going to use the positioning of center center. I'll put it semicolon there. Now let me go ahead and scroll down a little bit so you better view of what's going on. We don't need a border around this. You can see the search field has already been updated, and there is a bit of my image showing through, and it also shows up what I need to work on. So I see a border around the image. We don't need that. So let's get rid of it. So border: none. And if I click over here, and I see my border is gone.
Let's change the width and the height. Now I happen to know this particular image is 35x35. It's a square. So let's make the width 35 pixels and height 35 also. Let's see how that looks. Things are beginning to shape up nicely. Let me go ahead and close this down so you can do a better view. So there's my rounded area. Now I notice if I am in Live view here, and I go over it the pointer should switch to a hand icon, and it's not happening.
So let's specify that in my rule with cursor: pointer, and let's check it out. That's working perfectly. Now I've got just a few remaining issues with the Search widget all of them are text related. Let's tackle them in the next lesson.
Get unlimited access to all courses for just $25/month.Become a member
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.
Your file was successfully uploaded.