Bootstrap Tooltip: Creating tooltips

Table of contents:

Bootstrap Tooltip: Creating tooltips
Bootstrap Tooltip: Creating tooltips
Anonim

How to make your site attractive to visitors? This question worries almost all owners of Internet resources: merchants, bloggers, owners of small and large businesses, travelers and simply creative people who have something to tell the world.

Why should a website be beautiful and functional?

The number of visits depends on the theme of the site and its target audience, people's interest in a particular product, investment, promotion, content and many other factors. But it cannot be denied that the site is "greeted by clothes." It is the first and main page of the resource that is its face, the calling card, by which the visitor must understand whether he wants to spend his time on further viewing of the content.

bootstrap tooltip
bootstrap tooltip

And there is no room for error! According to the research of one of the technical universities in the USA, the visitor gets the first impression of the site in less than a second. On average, a person “scans” a site in 3 seconds. Lightning speed, right?!

Up to 70% of the success of a resource depends on how the main page looks. The first thing people notice islogo, but the second is navigation. And if everything is more or less clear with the logo, then it’s worth breaking your head over the navigation, menu and convenience of the site’s ergonomics. A reasonable question arises: "How to decorate your site, make it as functional and convenient as possible, but at the same time beautiful?" There are many unusual ideas to offer, but one of the most interesting is tooltips.

What are tooltips? In addition to being a great mechanism for improving the functionality of the site, tooltips are a tool that allows the user to see an explanation for a particular image when hovering over an icon, word or picture.

Tools for working with tooltips

Bootstrap is the best tool for creating tooltips. It's an easy-to-learn set of templates for building apps and websites written in HTML, CSS, Sass, and JavaScript.

bootstrap tooltip not working
bootstrap tooltip not working

To be specific, tooltips use one of the graphical elements of the Bootstrap template - Tooltip.

The Bootstrap framework was created for "Twitter" and was originally called "Twitter Blueprint". After some changes in 2012, it received a 12-column grid, became adaptive and acquired the familiar name - Tooltip. A tooltip is an element that pops up when you hover over a specific element on the monitor screen.

Creating a hint

You can create a Bootstrap Tooltip using attributesdata, as well as by activating the "Java Script" elements. There are two main ways to create an HTML Bootstrap Tooltip. The essence of the first is to apply the attribute and attribute title (title), which will contain the hint text. The tooltip will pop up at the top (default setting). It's worth remembering that the tooltip needs to be initialized, since automatic initialization has been deprecated in the "Twitter bootstrap" for performance reasons.

bootstrap tooltip example
bootstrap tooltip example

In order to initialize tooltips, special JavaScript is used, in which the tooltip method is restored for all elements that have an attribute. The essence of the second method is to activate a tooltip using the "JavaScript" code with the participation of the jQuery library by writing a tool class that includes a tooltip. The method is similar to the first one, except for the element selection method. You can enable hints in "Java Script" in the way shown below.

Script
Script

Bootstrap tooltip example

There are four main options for positioning tooltips: on the left and right edges, and above and below the element.

script from above
script from above

Hint from above

Hint on the right
Hint on the right

Hint right

Hint at the bottom
Hint at the bottom

Hint at the bottom

Hint on the left
Hint on the left

Hint left

Closing script
Closing script

Using tooltips

There are many uses for the Bootstrap Tooltip. You can insert tooltips so that the user can understand the translation of text from a foreign language in the text. Tooltips can also be used as a tool to help the user understand the meaning of the buttons on the panel when hovering over them. Bootstrap Tooltip templates are often used on the websites of various organizations to create a subscription to company news. This keeps customers up to date and also allows visitors to receive new information, such as discount rates, offers, changes within the company.

bootstrap tooltip html
bootstrap tooltip html

Consider an example where a user needs to enter their email address in order to subscribe to a newsletter. The task of ensuring that the client audience subscribes to news is most easily achieved using HTML5 and the required attribute. The tooltip hint in this case is needed in order for the user to understand the sequence of actions. For example, after entering the email address, I checked the box: "I agree to receive company news to the email address." Below is an example of the form code.

Tooltip
Tooltip

Installing this code into the HTML Bootstrap Tooltip is easy. But the benefits are significant. Now consumers know all the news of the company. This is a kind of free advertising.

bootstrap tooltip html content
bootstrap tooltip html content

Main mistakes when creating popupshints

What to do if Bootstrap Tooltip doesn't work? The first and main mistake where the tooltip attribute won't work is if the tooltip is not enabled. In order to activate it, you need to use a special code.

Tooltip Initialization
Tooltip Initialization

This method allows you to initialize absolutely all tooltips on a web page.

The second common mistake is not having jQuery in the header.

Tooltip error
Tooltip error

There is a necessary condition for the link to work correctly - a data processing function like "Java Script" must be specified.

Java script
Java script

Tooltip properties

At its core, the Tooltip component is designed to display tooltips when you move the mouse pointer over one or another part of the page. But, in addition to the location of the tooltip on the right, left and top with the help, tooltip has the following properties:

  • Active. Using the true property in the Bootstrap Tooltip allows tooltips to be displayed, while setting the same property to false means no tooltips can be displayed.
  • AutoPopDelay is the time at which tips are displayed.
  • AutoPopDelay. Represents the amount of time the mouse cursor must be hovering over an element for the tooltip to appear.
  • IsBaloon. If the value of the HTML Bootstrap Tooltip tooltip is true, then the tooltip will take the form of a cloud.
  • ToolTipIcon. Represents the character that is displayed in the windowhints.
bootstrap tooltip html true
bootstrap tooltip html true

Tooltipster

In order to create beautiful tooltips, for example, on a site created on Wordpress, it is not necessary to know the language of web developers thoroughly. It is enough to know about the existence of such a plugin (extension) as Tooltipster. From the name it is clear that this plugin is based on Tooltip and is surprisingly similar to it in its properties and purpose. What is this plugin for? It allows you to create the necessary HTML markup inside the tooltip.

Tooltips Example
Tooltips Example

The work of the plugin is based on the insertion of shortcuts on the page. Contains all the basic HTML Bootstrap Tooltip attributes: content (data-tooltip-content), title, position, trigger, etc. This allows you to change the theme, font, tooltip size, color, insert an image, and more.

Recommended: