You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To change grid width (columns count), to addition to `width` option, CSS rules
180
-
for `.grid-stack-item[data-gs-width="X"]` and `.grid-stack-item[data-gs-x="X"]` have to be changed accordingly.
178
+
GridStack makes it very easy if you need [1-12] columns out of the box (default is 12), but you always need **2 things** if you need to customize this:
179
+
180
+
1) Change the `columns` grid option when creating a grid to your number N
181
+
```js
182
+
$('.grid-stack').gridstack( {columns:N} );
183
+
```
184
+
185
+
2) and change your HTML accordingly if **N < 12** (else custom CSS section next). Without this, things will not render/work correctly.
`gridstack-extra.css` (and `gridstack-extra.min.css`) defines CSS for grids with custom [1-12] columns. Anything more and you'll need to generate the SASS/CSS yourself (see next).
195
+
196
+
See example: [2 grids demo](http://gridstack.github.io/gridstack.js/demo/two.html) with 6 columns
197
+
198
+
## Custom columns CSS
199
+
200
+
If you need > 12 columns or want to generate the CSS manually (else see above) you will need to generate CSS rules for `.grid-stack-item[data-gs-width="X"]` and `.grid-stack-item[data-gs-x="X"]`.
181
201
182
202
For instance for 3-column grid you need to rewrite CSS to be:
183
203
@@ -205,13 +225,15 @@ For 4-column grid it should be:
205
225
206
226
and so on.
207
227
208
-
Here is a SASS code snippet which can make life easier (Thanks to @ascendantofrain, [#81](https://github.com/gridstack/gridstack.js/issues/81) and @StefanM98, [#868](https://github.com/gridstack/gridstack.js/issues/868)):
228
+
Better yet, here is a SASS code snippet which can make life much easier (Thanks to @ascendantofrain, [#81](https://github.com/gridstack/gridstack.js/issues/81) and @StefanM98, [#868](https://github.com/gridstack/gridstack.js/issues/868)) and you can use sites like [sassmeister.com](https://www.sassmeister.com/) to generate the CSS for you instead:
Copy file name to clipboardExpand all lines: doc/CHANGES.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ Change log
24
24
25
25
## v0.5.2-dev (upcoming changes)
26
26
27
+
- grid options `width` is now `columns`, and `height` is now `maxRows` which match what they are. Old names are still supported for now (with console warnings). Also various fixes for custom # of columns and re-wrote entire doc section ([#1053](https://github.com/gridstack/gridstack.js/issues/1053)).
27
28
- fix widgets not animating when animate: true is used. on every move, styles were recreated-fix should slightly improve gridstack.js speed ([#937](https://github.com/gridstack/gridstack.js/issues/937)).
28
29
- fix moving widgets when having multiple grids. jquery-ui workaround ([#1043](https://github.com/gridstack/gridstack.js/issues/1043)).
29
30
- switch to eslint ([#763](https://github.com/gridstack/gridstack.js/issues/763)).
-`handleClass` - draggable handle class (e.g. `'grid-stack-item-content'`). If set `handle` is ignored (default: `null`)
80
-
-`height` - maximum rows amount. Default is `0` which means no maximum rows
80
+
-`columns` - amount of columns (default: `12`)
81
+
-`maxRows` - maximum rows amount. Default is `0` which means no maximum rows
81
82
-`float` - enable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html)
82
83
-`itemClass` - widget class (default: `'grid-stack-item'`)
83
84
-`minWidth` - minimal width. If window width is less than or equal to, grid will be shown in one-column mode (default: `768`)
@@ -93,21 +94,20 @@ gridstack.js API
93
94
-`verticalMargin` - vertical gap size (default: `20`). Can be:
94
95
* an integer (px)
95
96
* a string (ex: '2em', '20px', '2rem')
96
-
-`width` - amount of columns (default: `12`)
97
97
98
98
## Grid attributes
99
99
100
100
-`data-gs-animate` - turns animation on
101
-
-`data-gs-width` - amount of columns. Setting non-default value must be supported by equivalent change in CSS, [see docs here](https://github.com/gridstack/gridstack.js#change-grid-width).
102
-
-`data-gs-height` - maximum rows amount. Default is `0` which means no maximum rows.
101
+
-`data-gs-columns` - amount of columns. Setting non-default value must be supported by equivalent change in CSS, [see docs here](https://github.com/gridstack/gridstack.js#change-grid-columns).
102
+
-`data-gs-maxRows` - maximum rows amount. Default is `0` which means no maximum rows.
103
103
-`data-gs-current-height` - current rows amount. Set by the library only. Can be used by the CSS rules.
104
104
105
105
## Item attributes
106
106
107
-
-`data-gs-x`, `data-gs-y` - element position. Note: if one is missing this will `autoPosition` the item
108
-
-`data-gs-width`, `data-gs-height` - element size
109
-
-`data-gs-id`- good for quick identification (for example in change event)
110
-
-`data-gs-max-width`, `data-gs-min-width`, `data-gs-max-height`, `data-gs-min-height` - element constraints
107
+
-`data-gs-x`, `data-gs-y` - (number) element position in row/column. Note: if one is missing this will `autoPosition` the item
108
+
-`data-gs-width`, `data-gs-height` - (number) element size in row/column
109
+
-`data-gs-id`- (number | string) good for quick identification (for example in change event)
110
+
-`data-gs-max-width`, `data-gs-min-width`, `data-gs-max-height`, `data-gs-min-height` - element constraints in row/column
111
111
-`data-gs-no-resize` - disable element resizing
112
112
-`data-gs-no-move` - disable element moving
113
113
-`data-gs-auto-position` - tells to ignore `data-gs-x` and `data-gs-y` attributes and to place element to the first available position. Having either one missing will also do that.
0 commit comments