簡體   English   中英

部分使工具提示文本變粗

[英]Partially making tooltip text bold

我正在嘗試將工具提示中的第一行文本設置為粗體。 下面的代碼是我目前擁有的,它不起作用。

  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>")
  

下面的截圖是上面代碼的結果(一些 CSS 用於設置工具提示的樣式等)

工具提示代碼的結果

誰能幫我這個? 如果您需要更多代碼來幫助我解決這個問題,我很樂意與您分享::)

對不起我的英語不好,這不是我的母語。 先感謝您!

嗨,您可以通過使用帶有 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>")

然后你在 css 中使用:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM