Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now to create a CSS rule to style our tip container, we're going to need to open the tooltip.css file. So from your text editor, choose File > Open, from the myTooltip folder let's go into includes and let's open tooltip.css. Now there are CSS rules in here which are controlling our layout and style, and down at the very bottom we have a comment for Tooltip. This is where we're going to add our own custom rules for the tooltip. So I'll just add a few lines here at the bottom and what we are going to want to do is target that tooltip_container.
Now it is an id, so we target that with the pound sign, tooltip_container, then beginning and ending bracket. Let's split these brackets open. Now the first property we're going to set is going to be the color of the type, so we're going to set color: # fff; for white Next line, we're going to set position of absolute, this way the tooltip with absolute positioning can hover over the top of other objects and have its position changed without any relation to the other divs on the page.
Next line, we're going to set padding of 20 pixels, that's going to set padding on the top right bottom and left. We're going to set a max-width of 200px, that way regardless of any content we put inside out there, the tooltip will never get wider than 200. And of course, you can customize this for other values. Next, we're going to set the background-color. Now we're going to use the RGBA color space. So we're going to type after background-color: rgba, beginning and ending parenthesis, then a semicolon.
Inside of the parenthesis we're to specify the red, then the green, then the blue and then the alpha. So to get black with RGBA, we need to set the RGB values all to 0. So I will type a 0 for red, 0 for green, 0 for blue, then .85. This is going to give us 85% Opacity. Next we want to specify rounded corners, and we still need to use some specific rendering engine flags. The first is going to be webkit.
This is going to target Chrome, Safari, Android and the iOS Platform. So -webkit-border-radius, colon, space. We are going to set this to 12px. Next, we're going to set the flag for the rendering engine that runs inside of Firefox, which is Mozilla. So I'm going to copy that entire line and then replace webkit with moz for Mozilla.
Then on the next line we're going to add the straight CSS3 property, which actually is supported in IE 9, and other browsers are starting to support the straight CSS property instead of using rendering engine flags. So we'll type border-radius: 12px. Once these properties are added, let's choose File > Save, and now let's open up the Internet Explorer version of the CSS file. So in the code editor, let's choose File > Open. Let's open tooltip_ie.css.
So inside of here we're going to target to tooltip_containers as well, #tooltip_container, beginning and ending bracket, split that open. Now IE 7 and 8 don't support the maximum width setting, so we're going to come in here and simply set a width of 200px. On the next line we're going to set background, colon, space, then we are going to type none with a semicolon.
So here we want to clear out all of the background settings, since IE 7 and 8 don't understand the RGBA setting for background-color. So we'll just set background to none. Then on this line, we're going to specify a background image and use that transparent PNG, so we're going to type background-image: url(../images/ie_transparency.png);.
So again, we're setting the width, because IE 7 and 8 don't understand max-width. We're clearing out the background to get rid of the background color we specified in the tooltip.css, and then the background image we're bringing in with the semi-transparent PNG. That's going to gives us the same effect as the CSS3 is giving us in the other browsers. Now again, if we go back to the index.html file and then scroll to the top, remember we're only bringing in this CSS rule for IE 7 and 8. So other browsers are going to completely ignore everything on line 9 through 12.
They are going ignore the Google Shiv, they are going to ignore the tooltip.css; only IE 7 and 8 are going to see this. So now with our CSS rules in place, let's come back to our project folder, let's open up the HTML file up in a browser, let's hit Reload, and we should see the This is my tooltip in the lower left-hand corner here. We see our rounded corners. We see that the background is 85% opaque against the blue background, and we see that the container is actually showing up after the footer element. Now even though we did specify absolute positioning on this object, we haven't given it a top or a left property yet.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101478 Viewers
61 Video lessons · 88242 Viewers
71 Video lessons · 72114 Viewers
56 Video lessons · 103875 Viewers
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.