问题
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