Here's an example I've seen recently
HTML
Here are a few problems with this approach:
- if you're doing it this way you're not only using the Bootstrap CSS file (which to be honest is a little bloated) but you're also using Bootstrap JS
- your code is not semantic
- your code has a few extra accessibility issues
It would be more semantic if the markup was something like…
HTML
...but that doesn't really solve any performance issues your users are experiencing because of all the extra goodies Bootstrap includes that you're not using – and it doesn't solve the accessibility issues. That's why it would be nicer if we wrote the markup as…
HTML
Here's the thing. Not only is this less markup, but here's all the CSS you'll need to put in a tooltip.
CSS
It really is that simple to display a tooltip directly above some text and to make the content of the tooltip directly accessible.
A couple little notes - if you want to display the tooltip on the bottom of the you'll have to adjust the bottom values for both the before and after pseudoclass rules and if you want to display the tooltip with a different font or font-size you'll have to adjust those on the before and after pseudoclasses as well. All the detailed customization aside, this should get to started down the road to ditching Bootstrap.
Happy coding.
No comments:
Post a Comment