"Enhance Your Website with jQuery UI Tooltips Featuring HTML Content

Is there a way to customize the appearance of tooltips using jQuery UI Tooltip? I want to format tooltips similar to the image shown below for HTML content.

Example:

JavaScript:

 $(function () {
     $.widget("ui.tooltip", $.ui.tooltip, {
         options: {
             content: function () {
                 return $(this).prop('title');
             }
         }
     });

     $('[rel=tooltip]').tooltip({
         position: {
             my: "center bottom-20",
             at: "center top",
             using: function (position, feedback) {
                 $(this).css(position);
                 $("<div>")
                     .addClass("arrow")
                     .addClass(feedback.vertical)
                     .addClass(feedback.horizontal)
                     .appendTo(this);
             }
         }
     });
 });

CSS:

.tooltip-div {
            height: 144px;
            margin: 0 auto;
            padding: 0;
            width: 280px;
            }
            .tooltip-top {
            background-color: #FAF9DD;
            border: 1px solid #D8D8D8;
            float: left;
            height: 153px;
            padding: 0;
            width: 258px;
            }
            .tooltip-area {
            color: #7F7F7F;
            float: left;
            font-family: 'open_sanssemibold_italic';
            font-size: 15px;
            height: 110px;
            margin: 0 auto;
            padding: 18px 0 0 32px;
            width: 227px;
            }
            /*.toltip-arrow {
            background: url("images/toltip-arrow.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
            float: left;
            height: 22px;
            margin: 65px 0 0 -1px;
            width: 14px;
            }*/
            .tooltip-close {
            float: right;
            height: 13px;
            margin: 9px 8px 0 0;
            width: 13px;
            }

  .ui-tooltip, .arrow:after {
       background:  #FAF9DD; 

  }
  .ui-tooltip {
      /*padding: 10px 20px;
      color: white;
      border-radius: 20px;
      font: bold 14px"Helvetica Neue", Sans-Serif;
      text-transform: uppercase;
      box-shadow: 0 0 7px black;
    */
  }
  .arrow {
      width: 70px;
      height: 16px;
      overflow: hidden;
      position: absolute;
      left: 50%;
      margin-left: -35px;
      bottom: -16px;
  }
  .arrow.top {
      top: -16px;
      bottom: auto;
  }
  .arrow.left {
      left: 20%;
  }
  .arrow:after {
      content:"";
      position: absolute;
      left: 20px;
      top: -20px;
      width: 25px;
      height: 25px;
      box-shadow: 6px 5px 9px -9px black;
      -webkit-transform: rotate(45deg);
      -moz-transform: rotate(45deg);
      -ms-transform: rotate(45deg);
      -o-transform: rotate(45deg);
      transform: rotate(45deg);

  }
  .arrow.top:after {
      bottom: -20px;
      top: auto;
  }
}

Answer №1

Give this a try:

CSS

.arrow {
    bottom: -16px;
    height: 10px;
    position: absolute;
    right: -13px;
    top: 50%;
    width: 15px;
}
.arrow.top {
    /*top: -16px;
    bottom: auto;*/
}
.arrow.left {
    left: 20%;
}
.arrow:after {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
    border-bottom: 10px solid rgba(0, 0, 0, 0);
    border-left: 13px solid #FAF9DD;
    border-top: 10px solid rgba(0, 0, 0, 0);
    bottom: 0;
    box-shadow: 6px 5px 9px -9px #000000;
    content:" ";
    position: absolute;
    right: 0;
}
.arrow.top:after {
    /* bottom: -20px;
    top: auto;*/
}

SCRIPT

$('[rel=tooltip]').tooltip({
    position: {
        my: "center bottom+90",
        at: "left-170",
        using: function (position, feedback) {
            $(this).css(position);
            $("<div>")
                .addClass("arrow")
                .addClass(feedback.vertical)
                .addClass(feedback.horizontal)
                .appendTo(this);
        }
    }
});

See the Demo Here

Answer №2

Check out this cool example:

jsfiddle.net/abc123/example

Implement a tooltip that aligns to the left side.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Generating a random selection of files from a directory and distributing them randomly

In an attempt to create a command for my Discord.js bot that selects a random image from a folder and sends it, I am facing an issue. The array containing the images cannot be set manually due to the constantly changing number of images in the folder. The ...

Issue: nodebuffer is incompatible with this platform

Currently, I am attempting to utilize the Shpjs package in order to import a Shape file onto a Leaflet map. According to the Shpjs documentation: shpjs Below is the code snippet I am working with: const [geoData, setGeoData] = useState(null); //stat ...

Incorporating the JqueryUI menu into an AngularJS project

We are facing an issue with integrating JqueryUI menus into our AngularJS application. In our Layout.js file, we are attempting the following: OURApp.controller('leftBarCtrl', ['$scope', function ($scope) { $scope.init = function ( ...

Tips for designing a unique mosaic using flex technology

I am attempting to design a unique mosaic layout using flexbox that resembles the image provided: https://i.sstatic.net/jrHvb.jpg Each box should have a width equivalent to one-third of the parent container, except for box 4 which needs to be double the ...

Tips for sharing the scope using module.exports

Within handler.js, I have exported 2 functions: one for initialize() and the other for handle(). The initialize function is used to dynamically load the handler based on the application settings. I have a shared variable called var handler outside the modu ...

Utilize the body tag to divide elements in ReactJS

Is there a way to assign different body tags to specific components? For example, I want to apply one body tag to the dashboard component and a different one for the sign up page component. ...

Angular is programmed to detect any alterations

Upon detecting changes, the NgOnChanges function triggers an infinite service call to update the table, a situation that currently perplexes me. Any assistance on this matter would be greatly appreciated. Many thanks. The TableMultiSortComponent functions ...

Providing real-time results as numbers are added together

I need assistance in calculating a price inclusive of VAT based on a user-entered VAT rate. Is it possible to show the result in an input box dynamically as the user inputs the VAT rate and price, without requiring them to click a button or resubmit the fo ...

Exploring JSON data with JQuery: A comprehensive guide to looping through with each

I am currently facing an issue with looping through cached JSON data obtained from an Ajax call. Specifically, I keep receiving the error message 'Cannot read property 'title' of undefined'. Can someone provide assistance? $.each(cach ...

There were no visible outputs displayed within the table's tbody section

import React from 'react'; export default class HelloWorld extends React.Component { public render(): JSX.Element { let elements = [{"id":1,"isActive":true,"object":"Communication","previ ...

The strategic manipulation of numerous elements within a group

I am interested in finding out the safe limits for DOM manipulation using jQuery to avoid freezing the browser. What are the most efficient methods for mass manipulation of the DOM? Typically, I may need to handle lists containing up to 40k li elements. ...

What advantages does declaring a backing model "class" that closely resembles the GraphQL "Type" bring when using GraphQL?

I appreciate the Universal Relay Boilerplate for its meticulous organization and thoughtful structure compared to other boilerplates. It seems like they really put a lot of effort into ensuring everything is well-planned from the start, which is not always ...

Switching a component in Mui App transforms the entire aesthetic

I'm currently working on a project using Mui and the Material Kit theme. While I initially tried to customize the default components provided by Material Kit using custom CSS, I found that I was unable to override the styles as expected. Consequently, ...

Sending image id as a parameter to a MySQL query in PHP using jQuery

Having trouble passing image ids to mysql queries. I've tried the following code but keep getting an Undefined index x error. I've checked multiple Stack Overflow answers without success. echo "<img src=http://localhost/ss/img/".$p['pat ...

The sequence of divs in a language that reads from right to left

Is there a way in HTML to designate a set of divs so that they automatically align from left to right for languages that read left to right, and alternatively, flow from right to left for languages that read right to left? This means that the direction of ...

Looking to retrieve the raw HTTP header string in Node.js using express.js?

Currently, I am utilizing Node.js and express.js for my work. The project I am currently working on requires me to access the raw strings of the HTTP headers (charset and accepted). In express.js, there is a function available that can provide the charset ...

Guide to selecting all checkboxes on a website using Selenium in Python by implementing a loop

Currently, I am working on a Python program to automatically check all checkboxes on a specific webpage. Although I can successfully select a single checkbox, I am facing challenges when trying to iterate through a loop of elements that contain checkboxe ...

Ensuring the accuracy of user input in JavaScript, even after fixing a mistake and submitting again, will not cause the code to exit the else clause

I am currently working on a coupon code field that needs to accept a specific set of coupon keys. Below is the code I have written for validation. If a user enters an invalid key at first, they receive an alert saying "Invalid Key." However, if they corr ...

Setting an AJAX response as the value of a modal form

One of the functionalities on my website involves a button that, when clicked, triggers the opening of a modal form and sends an ajax request to a php page. This request includes an id from a specific table in the database. The php page then retrieves a ...

Exploring the dynamic attributes of an Object in React

My task involves checking for the presence of a placeholder in the "all" string within the alertDetails object. I specifically need to access the email, sms, and fax properties which are generated dynamically based on user input (this code is part of an al ...