简体   繁体   English

更改drillUpButton文本的字体颜色

[英]Change the font color of drillUpButton text

I wonder how to change the font color of drillUpButton text .我想知道如何更改rillUpButton text 的字体颜色 I tried css to extract the element like: g.highcharts-button highcharts-drillup-button highcharts-button-normal text{color: blue;} However it doesn't work.我尝试使用 css 来提取元素,例如: g.highcharts-button highcharts-drillup-button highcharts-button-normal text{color: blue;} 但是它不起作用。 Button Picture按钮图片

The drillUpButton API only provide how to change the theme of the button itself but has nothing to do with the text. rillUpButton API 只提供了如何更改按钮本身的主题,与文本无关。

drillUpButton: {
        relativeTo: 'spacingBox',
        position: {
            y: 10,
            x: 0
        },
        theme: {
           color: "#5ab7f5",
            fill: 'white',
            'stroke-width': 2,
            stroke: '#5ab7f5',
            r: 5,
            states: {
                hover: {
                    color: 'white',
                    fill: '#5ab7f5'
                },
                select: {
                    fill: '#5ab7f5'
                }
            }
        }
    },

Here is the link for reference这是参考链接

If someone wants to avoid using CSS selectors, you can add CSS style to text button using style property.如果有人想避免使用 CSS 选择器,您可以使用style属性为文本按钮添加 CSS 样式。

theme: {
  style: { color: "red" },
  ...
}

You didn't quite go far enough to tspan and you're using color instead of fill.你没有走得足够远到tspan并且你正在使用颜色而不是填充。 You were also missing a couple "."你还漏掉了几个“。” when selecting the class.选课的时候。

Creating this rule seems to work创建此规则似乎有效

g.highcharts-button.highcharts-drillup-button text tspan{
  fill: blue;
}

If you don't want to type all of that out .highcharts-drillup-button text tspan should work as well.如果您不想输入所有这些内容, .highcharts-drillup-button text tspan应该可以工作。

DEMO演示

You can change the color of the text by using the highchart drillup button css styling class to apply the color to the text.您可以通过使用 highchart 钻取按钮 css 样式类将颜色应用于文本来更改文本的颜色。 The reason why simple color:red property on it wont work because it is a svg created on the run and svg also sets the fill property for the text as well which overwrites the color.之所以简单的color:red属性不起作用,是因为它是在运行时创建的 svg 并且 svg 还为文本设置了填充属性,它会覆盖颜色。 On top of that you need to force your custom class colors by using the !important keyword for each property set.最重要的是,您需要通过为每个属性集使用!important关键字来强制自定义类颜色。 So just add the following class in your custom css and you drillup button text will change.因此,只需在您的自定义 css 中添加以下类,您的钻取按钮文本就会更改。

.highcharts-drillup-button text{
   color: red !important;
   fill: red !important;
}

Hope this helps.希望这会有所帮助。

Use this selector:使用这个选择器:

.highcharts-button-box+text {
  fill: red !important;
}

Example:示例:
http://jsfiddle.net/vwdfceLz/ http://jsfiddle.net/vwdfceLz/

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

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