is it possible to insert a line break in this tool

2019-07-21 00:56发布

i have a pretty map of the US:

http://upload.wikimedia.org/wikipedia/commons/a/a5/Map_of_USA_with_state_names.svg

i would like to implement a tooltip with multiline functionality such as here over the red square:

http://www.carto.net/papers/svg/gui/tooltips/

please help me get started on this. i will be offering a maximum bounty on this.

9条回答
老娘就宠你
2楼-- · 2019-07-21 01:23

Don't.

The title of the page is handed off to the browser and not rendered in the page; usually that means it shows up in the application's title bar. Actually rendering a newline would make the title bar twice as tall (or more, with multiple newlines) - and that's not going to happen.

查看更多
做个烂人
3楼-- · 2019-07-21 01:30

Add a <br/> where you want the break.

查看更多
我只想做你的唯一
4楼-- · 2019-07-21 01:32

You never cease to amaze me, I__! How many projects are you working on?

Tooltips are browser-generated quick popups; you should use \n to set the .title attribute in JavaScript.

查看更多
疯言疯语
5楼-- · 2019-07-21 01:35

A line break in html is <br />. You can add that anywhere you like.

FYI - there is no tag named 'field1', so your getElementsByTagName call will find nothing.

查看更多
迷人小祖宗
6楼-- · 2019-07-21 01:37

I achieved this by creating the tooltip value with <br/> from my server side.

查看更多
Root(大扎)
7楼-- · 2019-07-21 01:40

Apparently, this is a known problem and you have to handle it like this:

<desc>
   <tspan x="10" y="10">An orange</tspan>
   <tspan x="10" y="24.5">circle</tspan>
</desc>
查看更多
登录 后发表回答