Let's Start Building the Tooltip
Now that we've found a way to get the middle, let's get a skeleton of a tooltip to display. In this lesson, we will code a basic layout of a tooltip in HTML which we will further extend in the upcoming lessons.
We'll cover the following
SVG or PNG? #
At the end of the last lesson, we found the middle of some text we highlight. There’s still work to be done, like getting the middle of the first line when multiple are selected, and only having the event respond to selections (as of now it responds to clicks too), but I think the hard part is over. In a similar fashion, if you’re rapidly iterating on a product and you’re coding towards some work-in-progress designs, it would be wise to get 80% of the way there in CSS. Chances are, the last 20% of making things pixel perfect take disproportionately longer, and your efforts will be doubled when the design inevitably changes.
So, let’s make 80% of the tooltip.
We won’t spend too much time on styling. It’s a rectangle with a dark background and four icons separated by a thin divider. For the icons, they seem to use SVG over PNG.
Get hands-on with 1400+ tech skills courses.