最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - HighChart - Can draw line between Title and SubTitle - Stack Overflow

matteradmin5PV0评论

In HighChart, how can I make a green line appear between my title and my subtitle?

JSFiddle

title: {
    useHTML: true,
    text: 'Header Text in Line1 </br> Line&nbsp;2 Text',
    style: {
        "text-align": "center"
    }
},    

subtitle: {
    // useHTML: true,
    text: 'SubTitle',
    style: {
        "color": "red",
    }
}

In HighChart, how can I make a green line appear between my title and my subtitle?

JSFiddle

title: {
    useHTML: true,
    text: 'Header Text in Line1 </br> Line&nbsp;2 Text',
    style: {
        "text-align": "center"
    }
},    

subtitle: {
    // useHTML: true,
    text: 'SubTitle',
    style: {
        "color": "red",
    }
}

Share Improve this question edited Aug 30, 2019 at 9:41 41 72 6c 1,7806 gold badges22 silver badges36 bronze badges asked Aug 30, 2018 at 22:51 DhanaDhana 1,6584 gold badges24 silver badges40 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

What you'd need to do is modify the style attribute like this:

title: {
        useHTML: true,
        text: 'Header Text in Line1 </br> Line&nbsp;2 Text',
        style: {
            "text-align": "center",
            "border-bottom": "1px solid green"
        }
    },     

Output

You can make the title display:block and then set the left to 0px. Then set the width to 100%. Now the title spans the whole width of the chart. Now apply a bottom border of green color. You will get the desired effect.

In the style property of the title, you could give

        "width": '100%',
        "display": 'block',
        "left": 0

Have a look at this fiddle - https://jsfiddle/rwmntze8/

Hope this helps!

PS: Someone removed the original image containing the requirements, attached by the OP in the question, during the edits (You can find it in the edit revisions). I have attached it here for reference, in case someone thinks why the green line spans till the end.

Just need to add an empty css below, nothing more:

.highcharts-title {
  border-bottom: 1px solid black;
}

Doing it by pure CSS (not by setting element style using JS) gives you the best performance.

Live example: http://jsfiddle/fqes890o/

Post a comment

comment list (0)

  1. No comments so far