Niranj k Niranj k - 7 months ago 6
Javascript Question

How can i place a button always center of the graph

enter image description hereI have one start button.How can i place that start button always center of the graph also when i resize the window it should be always center of the graph.How can i do it?

Js:

$( window ).resize(function() {
var chart = $('#container').highcharts();
var textX = chart.plotLeft + (chart.plotWidth * 0.5);
var textY = chart.plotTop + (chart.plotHeight * 0.5);
$('. placeBtn').css('left', textX + (span.width() * -0.5));
$('. placeBtn').css('top', textY + (span.height() * -0.5));
});


var chart = $('#container').highcharts();

var textX = chart.plotLeft + (chart.plotWidth * 0.5);
var textY = chart.plotTop + (chart.plotHeight * 0.5);

$('. placeBtn').css('left', textX + (span.width() * -0.5));
$('. placeBtn').css('top', textY + (span.height() * -0.5));


Jsfiddle:https://jsfiddle.net/7skvx8L5/2/

Answer

Remove position: absolute, and add text-align: center to the row.

.placeBtn {
    /* position: absolute; */
    width:94px;
    background-color:#ccc !important;
    border-color: #000 !important;
    color: #000000;
}

.col-lg-12 {
  text-align: center;
}

WORKING EXAMPLE

If you don't like calling text-align for every .col-lg-12, you can add a class to that row like this:

<div class='col-lg-12 center'>

and in stylesheet:

.center {
    text-align: center;
}

Or do you mean this:

WORKING EXAMPLE