Wehavethefinalresultdownhere, andthetooltipisessentially a littleelementthatjustappearsinsomepositionaroundtheelementtoeletyouknow a littlebitmoreinformation.
Thepurposeof a tooltipisnottolookfancybutspecificallytohelptheuserunderstandsomethingaboutwhattheyareinteractingwith.
Sofrom a usabilitystandpoint, let's saythislittlepinkbox I havehereisanacronymandyouwanttobeabletoletthemknowwhatthatacronymstandsfor.
Ormaybethereisanelementcalledtoactionwhereifyouhoveroverit, itletsthemknowadditionalinformationtohelpthemunderstandhowtointeractwiththatelement a littlebitbetter.
There's anendlessamountofreasonswhyyoumightwant a tooltip, butthepurposeofthislessonisnotnecessarilytoshowyouthe y ofthetooltip.
Sopositionabsolutesgonnagiveusmoreflexibilitythatindextojust a littlebitabovethedefault, whichtotooltipwillbeatzero, andthenthisonewillbringitupjust a littlebit.
Wedon't wantittobebehinditsparentelementdisplayNonebydefault, with 200 pixelspadding 10 pixels.
Nowwecan't findoutthatwecan't createthatwith a percentage.
But I alsowanttohave a dynamictooltippositionfromthebottombecausethatelementcouldbeanysize.
If I wanttoadd a tiltedtoanyelement, notjust a specific, hardcodedheight, soitneedstobe 100% fromthebottom, butitneedstohaveanadditionalfivepixels, andthewaywecancombine a percentageandpixelvalueisthroughthecouchCSSfunction.
Socheckthisout.
Let's gobacktoourCSS.
I'm gonnawrapthisintheCalHQfunctionlikethis, but I'm gonnasay, plusfivepixelsthatallowsustocombinedifferentvalues.
There I found a reallycoolarticleaboutthetransform.
Specifically, What I'm gonnadoisthisand I'lltellyouexactlywhy.
Sotranslate x Sotranslatethevalueforthetransformedpropertyonthe X axes, whichmeanshorizontally.
So I amtosay, negative 50%?
No, letmeshowyouwhatithappensandthenwe'regonnagofromthere.
Sonowwe'reperfectlyinthecenter.
So I moveditnegative 50% ofitswidthoversothatitisperfectlyinthecenter.
Thereasonwhy I usedtransformedtranslatorsbecausethisarticleeyes a greatarticle.
I have a linkinthefinalcodeAnditthisline 58 ofthefinalCSS.
Withthelinktothisarticle, it's basically I wantedtoknowOK, whywouldyouwanttousetranslateversusanabsolutepositionor, youknow, using a marginwhereyoucan, youknow, negativetheamountSoit's centered, whichwe'vedonebefore.
Butbecauseitcouldbefadinginandbecauseyoucouldhaveitslideuporslidedownintoposition, usingthetransferofpropertyis a nicerwayofhandlingitspositionbecauseit's a bitmoredynamic.
Hopefully, thatmakessense, and I didn't gooffon a tangentfornoreasonwhatsoever.
So I'm gonnacutthatout, andwhat I'm gonnadoisthis.
So I'm gonnaactuallygodowntothebottomand I'm gonnasaytooltip, Andthen I'm gonnacombinethatwiththeclassoftopandthentheafterpseudoelement I believeitwasbeforeactuallywaswth e stylewe'regoingforYes.
Thenwehavetooltiptopbeforethat's positiontogetthatinthetopcenterpositionabovethepinkelementandthentoldtotopafter, whichis a littlearrowinthebottominthecenter.
Thatisgood.
Somovingonthatwasthewasthebulkofthework.
I thinkbecausenowwhatwe'regonnabedoing, it's justpositioningtheWealreadystyledupthetooltip.