Positioning the tooltip to the left side

I need help with customizing a tooltip in my code. I want the tooltip text to be displayed on the next line and positioned on the left side. You can view a demo here.

<div id="demo">
   <p title="The tooltip text I want this in next line"> Tooltip 1</p>
   <p title="The tooltip text I want this in next line">Tooltip 2</p>
   <p title="The tooltip text I want this in next line">Tooltip 3</p>
   <p title="The tooltip text I want this in next line">Tooltip 4</p>
</div>

CSS:

.tooltip {
    display:none;
    font-size:12px;
    height:70px;
    width:160px;
    padding:25px;
    color:#eee;
}

JS

$("#demo img[title]").tooltip();

Answer №1

It appears that the jQuery UI Tooltip plugin is in use.

To customize the tooltip position, take a look at the official documentation. Here is an example of how you can set the position:

$("#example p[title]").tooltip({
    track: false,
    position: {my: "left top", at: "left bottom"}
});

Answer №2

No need for Javascript here...

Display the title attribute of elements in the following line

EXAMPLE: http://jsfiddle.net/XZWhJ/7/

[Your] HTML

<div id="demo">
  <p title="The tooltip text I want this in next line"> Tooltip 1</p>
  <p title="The tooltip text I want this in next line">Tooltip 2</p>
  <p title="The tooltip text I want this in next line">Tooltip 3</p>
  <p title="The tooltip text I want this in next line">Tooltip 4</p>
</div>

CSS

#demo p[title] {
    position: relative;
    margin-bottom: 1em; /* provide space for the tooltip */
}

#demo p[title]:hover:after {
    content: attr(title);
    position: absolute;
    left: 0;
    bottom: -1em; /* positioned below the parent element */
}

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

What is the process for retrieving the search function value in Node Js?

I have been working on creating a search bar functionality using the Express Framework in Node.JS, Handlebars, and MySQL. The connection to MySQL is all set up and functioning properly, I have installed body parser, and even tested the query directly in ph ...

Display just a fraction of a picture

Just recently, I had a surprising discovery when I right-clicked on the cross icon and noticed that the background image in the Tags section of the Ask Question page contained multiple icons beyond just the cross. Curious about how this was achieved, I sea ...

CSS style to choose the row in a bootstrap table with a specific class

This snippet is from a table created using Bootstrap: <div class="table-responsive"> <table class="table table-bordered table-striped"> <tbody> <tr> <td align="cent ...

Switching image when hovering with mouse using javascript

I am working on an HTML webpage and trying to make an image change when hovering over a div, but it doesn't seem to be working. Any suggestions? <!doctype html> <html> <head> <meta charset ="UTF-8"/> &l ...

What are the reasons for not accessing elements in a more "direct" way like elemId.innerHTML?

Recently, I came across a piece of JavaScript code that accesses HTML elements using the shorthand elementID.innerHTML. Surprisingly, it worked perfectly fine, but interestingly, most tutorials opt for the traditional method of using document.getElementByI ...

Synchronizing the scrolling of two elements with varying heights: A guide

There are two DIV elements in question: #page and #block : <div id="page"></div> <div id="block"></div> The #block element has a fixed position and contains long content with the property overflow:hidden. The #page element also c ...

Tips on relocating a button in a column located within a table header

Is there a way to adjust the positioning of the buttons in a thead to align with a colored border below it? <table> <thead> <!-- table extra buttons --> <tr style="border-bottom-style: solid; border-bottom-color: #FFE84D; ...

Configuring Firefox settings in Nightwatch

Is there a way to set Firefox preferences in nightwatch? I am trying to achieve the same thing in Java using nightwatch. To set Firefox preferences in nightwatch, you can use the following code snippet: FirefoxProfile profile = new FirefoxProfile(); prof ...

Ways to ensure a div stretches all the way down to the bottom of the

div { background-color: #bada55; width: 475px; float: left; margin-left: 30px; height: 100%; } html, body { height: 100%; min-height: 100%; } <div> </div> I am facing an issue with extending a div to the bottom of the screen. De ...

Reposition the Column, Filter popover within the MUI Data Grid Pro

I am working with the MUI Data Grid Pro to showcase my data. By default, the Data Grid Pro exhibits the toolbar on the left side. Although I managed to shift the toolbar to the right side, the popovers and menus retained their position on the left. My inte ...

Adjusting website design size when zooming and switching resolutions

<html> <style> body { background-color:#F1EEF2; } header { width:800px; margin-left:auto; margin-right:auto; } layout { min-width: 100%; min-height: 100%; } nav.header { width:800px; height:40px; background-color:#000000; color:#fef8f0; } ...

Redux persist isn't functioning properly as the rehydration process only happens one time

I am currently working with React version 15.4.2 and Redux, trying to persist my React/Redux state when the browser refreshes. Despite suggestions of using redux-persist, I encountered issues when following the basic instructions as the state resets to emp ...

Struggling to get your HTML to Express app Ajax post request up and running?

I’m currently in the process of creating a Node Express application designed for storing recipes. Through a ‘new recipe’ HTML form, users have the ability to input as many ingredients as necessary. These ingredients are then dynamically displayed usi ...

Chrome and Internet Explorer are not prompting to save passwords after the input type has been altered by a script

I've encountered an issue with a form that includes: <input type="password" id="password" /> I want to display some readable text temporarily, so I used the following code: $('#password').prop('type', 'text'); ...

having difficulty configuring gwt-button's corners to be rounded

Hey there, I'm having an issue with a button in my GUI that I created using GWT. I'm trying to round the corners of the button, but using border-radius doesn't seem to have any effect on its appearance. The style sheet I'm using is "co ...

After the page is reloaded, apply a class to the divs by selecting them based on the "data" attribute

I have a set of four cards labeled "card", each representing different body parts: eyes, torso, arms, and legs. <div class="card" data-lesson="eyes">eyes</div> <div class="card" data-lesson="torso">torso</div> <div class="card" ...

Can you choose and generate identical values using react-select?

I am working on implementing a multi Creatable feature where users can select a preset value or create a new value during the same interaction. To illustrate, here is my current render: import CreatableSelect from 'react-select/creatable'; functi ...

Exploring React components - comparing mount and shallow rendering techniques and practicing event simulation

Recently, I've been delving into testing React components and have encountered a challenge. Specifically, I am striving to simulate entry into the input field identified as 'componentCount' in my code. My experience with React spans less tha ...

Utilize JavaScript Datepicker within the RStudio Environment

Can anyone help me figure out how to add a javascript datepicker to my Shiny app? I'm not sure how to import and execute the code in R. Here is where I found the source code: http://jqueryui.com/datepicker/ I'd prefer to integrate this code into ...

Receiving Server Emissions in Vue/Vuex with Websockets

In my Vue component, I was using socket.io-client for WebSocket communication. Now that I've added Vuex to the project, I declared a Websocket like this: Vue.use(new VueSocketIO({ debug: true, connection: 'http://192.168.0.38:5000', })) ...