[英]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.