Is it possible to style a title? (and with CSS or js?) [duplicate]

断了今生、忘了曾经 提交于 2019-11-27 02:14:11

You can put newlines in your title attribute via HTML entities to force a line break in the text. Most browsers these days support this. This is the only change you can make to the native tooltip display of the browser.

<a href="real_link" title="check&#13;&#10;this&#13;&#10;out">foo bar</a>

See the above example on a web page.

As others have pointed out, there exist a large number of plugins for various JS libraries for making custom HTML tooltips which are styleable. Here is the top hit for the Google search "jquery tooltip plugin", reviewing 10 such plugins.

You can create a CSS-only tooltips using the :after and :hover pseudo-class:

<a href="#" class="class-with-tooltip">Link</a>
.class-with-tooltip:hover:after{
    content: 'Tooltip';
    position: absolute;
    padding: 5px;
    border: 1px solid gray;
    background: whitesmoke;
    font-size: 14px;
}

I'm not sure how this going to work in old browsers, but it works in all major browsers.

The position: absolute; is needed to prevent generated content from pushing the markup after the element.

It is not possible in CSS, since the tooltip popup is an OS native thingy, but please have a look at this tutorial (article + screencast + source code): http://net.tutsplus.com/articles/news/you-still-cant-create-a-jquery-plugin/ It describes how to roll your very own custom jQuery plugin that will do exactly what you are asking for.

You can't use straight CSS on the default title attribute, but you can use many JQuery tooltip plugins available to create new tool tips and those you can style with CSS.

http://www.1stwebdesigner.com/freebies/stylish-jquery-tooltip-plugins-webdesign/

You can do it with jQuery but there's no need for a plugin.

Assign the element(s) a class and then, after the document is ready, set the title attribute for that class. For instance...

$(".className").attr("title", "Your title here.");

No. There is no way you can style the "title" attribute of any HTML element. However, I would agree that there are many jquery plugins available to style the tooltip using the title attribute.

Try this. http://flowplayer.org/tools/tooltip/index.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!