简体   繁体   English

部分使工具提示文本变粗

[英]Partially making tooltip text bold

I'm trying to make the first line of text from my tool tip to be bold.我正在尝试将工具提示中的第一行文本设置为粗体。 The code below is what I currently have and it doesn't work.下面的代码是我目前拥有的,它不起作用。

  tooltip.html("<b>" + smartData[yearSlider][d3.select(this).attr("country")]["country"] + "</b> <br>" +
  "Total CO2 Emission excluding LULUCF" + "<br>" + 
  smartData[yearSlider][d3.select(this).attr("country")]["totalghgexlulucf"] + 
  "<br>" + "Total CO2 Emission including LULUCF" + "<br>" +
  smartData[yearSlider][d3.select(this).attr("country")]["totalghginclulucf"] +
  "<br>")
  

The screenshot below is the result of the code above (some CSS was used to style the tooltip, etc.)下面的截图是上面代码的结果(一些 CSS 用于设置工具提示的样式等)

Result of tooltip code工具提示代码的结果

Can anyone help me with this?谁能帮我这个? If you need more code to help me with this problem, I'm more than happy to share it with you: :)如果您需要更多代码来帮助我解决这个问题,我很乐意与您分享::)

Sorry for my bad English, it's not my native language.对不起我的英语不好,这不是我的母语。 Thank you in advance!先感谢您!

Hi you can solve this by using a span with a class and style the class in your css file:嗨,您可以通过使用带有 class 的跨度并在 css 文件中设置 class 的样式来解决此问题:

tooltip.html("<span class='tooltip-text-bold'>" + smartData[yearSlider][d3.select(this).attr("country")]["country"] + "</span> <br>" +
  "Total CO2 Emission excluding LULUCF" + "<br>" + 
  smartData[yearSlider][d3.select(this).attr("country")]["totalghgexlulucf"] + 
  "<br>" + "Total CO2 Emission including LULUCF" + "<br>" +
  smartData[yearSlider][d3.select(this).attr("country")]["totalghginclulucf"] +
  "<br>")

then you style in css using:然后你在 css 中使用:

.tooltip-text-bold{
    font-weight: 700;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM