Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8915571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:00:00+00:00 2026-06-15T05:00:00+00:00

I am creating a tooltip solely based on CSS. I have a span tag

  • 0

I am creating a tooltip solely based on CSS. I have a span tag with a class of tooltip and used data-tooltip attribute for the content.I would like to use data-tooltip-width in that span class and use that value to set the width of the content. So basically i should create a variable like this :

var twidth = $('.tooltip').data('tooltip-width');

But i can’t find out what i should do next. I have tried this but it didn’t work:

$('.tooltip[data-tooltip]:after').css({
 'width': twidth,
});

Somebody enlighten me how can i accomplish this. Below is CSS code:

 .tooltip[data-tooltip] {
  position: relative;
  text-decoration: none;
  border-bottom: solid 1px;

 }

.tooltip[data-tooltip]:before {
 content: "";
 position: absolute;
 border-top: 20px solid @color;
 border-right: 20px solid transparent;
 visibility: hidden;
 left:50%;
 bottom: 100%;

}

.tooltip[data-tooltip]:after {
 content: attr(data-tooltip);
 position: absolute;
 color: white;
 left:50%;
 bottom:150%;
 background: @color;
 padding: 5px 15px;
 display: inline-block;   
 visibility: hidden;
 white-space: nowrap;

 }        
.tooltip[data-tooltip]:hover:before, .tooltip[data-tooltip]:hover:after {
  visibility: visible;

 } `        
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:00:02+00:00Added an answer on June 15, 2026 at 5:00 am

    As far as I know, you can’t add CSS-Styles to ‘after’ Elements. The problem is, that jQuery writes to the ‘style’-Attribute when you use .css, this is however an attribute to style the element itself. There is no ‘after’ element to add the style to.

    Short:

    • Adding a css-style in jQuery to an ‘after’-element won’t do anything.
    • And (in CSS) attr() isn’t supported by any browser beyond ‘content’-attribute.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a little dynamic tooltip function. Basically if I have a link like
I want to generate tooltip based on a dynamically changing background image in css.
I have a function for creating a tooltip from a title. I am trying
I have been successful in creating a tooltip for text using code similar to:
I am creating a simple tooltip plugin, which shows title attribute contents as tooltip
I am creating a little diff -/ offset display and I would like to
I am using MFC CToolTipCtrl for creating tooltip for a button. Now I have
I have a-facebook-like mentioning feature in my app. When creating posts or comments user
I'm creating a jQuery plugin to display a tooltips. I would like to add
I have a div that acts as a tooltip-like popup when the mouse hovers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.