0

I am using gridstack for the first time and I am having trouble with the horizontal margins. Clearly there is something in my css that is making my items too wide.

I see in the demos that gridstack.css has left and right set at 10px each, and I am using that same default css.

I have set gridstack up to use 6 columns as follows:

<div id="container" class="grid-stack grid-stack-6"> 
  <div class="grid-stack-item"
    data-gs-x="0" data-gs-y="0"
    data-gs-width="3" data-gs-height="2">
        <div class="grid-stack-item-content">
        <i class="icon-lock-open pinDiv warning"></i>
        <i class="icon-cancel-circled"></i>
        PRE MAP
  </div>
 <div class="grid-stack-item lockAspect"
    data-gs-x="3" data-gs-y="0"
    data-gs-width="3" data-gs-height="2">
        <div class="grid-stack-item-content" style="background:pink;">
        <i class="icon-lock pinDiv warning"></i>
        <i class="icon-cancel-circled"></i>
        POST MAP
        </div>
  </div>
</div>

I am using the following options:

DEFAULT_GRIDSTACK_OPTIONS =  {
    cellHeight: 150,
    verticalMargin: 10,
    width: 6
};

and I am including gridstack-extra as well as gridstack.css.

Why do my items have no horizontal margin at all?

thanks so much

Tamar Cohen
  • 1
  • 1
  • 4

2 Answers2

0

i haved same problem. I fixed

.grid-stack > .grid-stack-item > .grid-stack-item-content{
   left: 3px;
   right: 3px;
}

But not best practices, i want config in javascript similar config option verticalMargin

var optionsLayoutDesign = {
            width: 6,
            float: true,
            removable: '.trash',
            verticalMargin:6,
            cellHeight:50,
            removeTimeout: 200,
            acceptWidgets: '.grid-stack-item',
            animate :true,
        };
$('#layout-design').gridstack(optionsLayoutDesign);
0

you need to style the class

grid-stack-item-content

instead of

grid-stack-item

john Smith
  • 17,409
  • 11
  • 76
  • 117