How does Stack Overflow display tooltip for the questions?

丶灬走出姿态 提交于 2020-01-04 02:52:34

问题


While we ask a question, SO shows related questions. If we hover on the questions the content is displayed as a tooltip which contains linebreaks, indentations etc. What technique SO uses for it? How to display tooltips wit the formatting?

Other than, jquery/javascript is there any simple way to achieve it?

Was just wondering, should i ask this on Meta?


回答1:


It is just a title attribute on the hyperlink, plain and simple.

<a href="..." title="The value is approximately
        3.14159265
    but for simplicity you can always round it
    to exactly 3.0">What is the value of Pi?</a>

In IE, Chrome & Safari, it honors the line breaks a bit more strictly than say Firefox or Opera.




回答2:


I took this html actually from stackoverflow. Here is no magic here:

Here's a dumb question which I can't find an answer to:
I have a table which contains 20 fields, a few of which are date/time. I am interested in pulling all the fields. I would like to  … ">Selecting fields in SQL Select statements (Dumbest SQL Question)</a>

As you see, title can have line breaks!



来源:https://stackoverflow.com/questions/3320081/how-does-stack-overflow-display-tooltip-for-the-questions

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