gridstack.js icon indicating copy to clipboard operation
gridstack.js copied to clipboard

verticalMargin doesn't seem to be working

Open csavage1994 opened this issue 10 years ago • 3 comments

I've been trying to get the verticalMargin option to work but have had no success. The code I'm currently running is as follows:

HTML:

<div class="grid-stack">
    <div class="grid-stack-item"
        data-gs-x="0" data-gs-y="0"
        data-gs-width="4" data-gs-height="2">
            <div class="grid-stack-item-content">what can go in here?</div>
    </div>
    <div class="grid-stack-item"
        data-gs-x="4" data-gs-y="0"
        data-gs-width="4" data-gs-height="4">
            <div class="grid-stack-item-content scroll">
                <form>
                <input type="text">
                </form>
            </div>
    </div>
</div>

And the JS:

$(function () {

    var options = {
        verticalMargin: '2em',
        animate: true
    };
    $('.grid-stack').gridstack(options);
});

And the result:

image

I've tried passing in integers and strings, neither of which affect the vertical margins of the grid.

csavage1994 avatar Oct 24 '16 18:10 csavage1994

A quick workaround for anyone else having this issue:

div.grid-stack > .grid-stack-item[data-gs-width="12"]  { width: 100% }
div.grid-stack > .grid-stack-item[data-gs-width="11"]  { width: 91% }
div.grid-stack > .grid-stack-item[data-gs-width="10"]  { width: 82.7% }
div.grid-stack > .grid-stack-item[data-gs-width="9"]  { width: 74.4% }
div.grid-stack > .grid-stack-item[data-gs-width="8"]  { width: 66.1% }
div.grid-stack > .grid-stack-item[data-gs-width="7"]  { width: 57.8% }
div.grid-stack > .grid-stack-item[data-gs-width="6"]  { width: 49.5% }
div.grid-stack > .grid-stack-item[data-gs-width="5"]  { width: 41.2% }
div.grid-stack > .grid-stack-item[data-gs-width="4"]  { width: 32.9% }
div.grid-stack > .grid-stack-item[data-gs-width="3"]  { width: 24.6% }
div.grid-stack > .grid-stack-item[data-gs-width="2"]  { width: 16.3% }
div.grid-stack > .grid-stack-item[data-gs-width="1"]  { width: 7% }

You need to leave a little bit of space between each element instead of setting them equal to exactly 100/numOfRows, however this isn't a permanent fix

csavage1994 avatar Oct 25 '16 15:10 csavage1994

Hi, @csavage1994 ! Why does modifying the width impact the vertical margin? The verticalMargin option should properly set the vertical margin. If you're having a problem, maybe you could spin up a quick little jsfiddle for us to take a look at?

radiolips avatar Nov 01 '16 17:11 radiolips

Closing due to inactivity. If you're still having a problem, please reopen the ticket and provide a jsfiddle. Hope you were able to get your problem solved. Thanks!

radiolips avatar Apr 20 '17 20:04 radiolips