Problem with element positioning in a multi-column layout
Question
How to control the position of the elements in the cells in columns? On the left side, I have the map element, and on the right, I have a Text and Image. As seen in the screenshot below, the elements on the right are positioned after the map.

A similar problem is there in this codepen (Grapesjs Custom UI by @artf ) too.

Answers (3)
You can add this to pluginOpts inside grapesjs.init:
const editor = grapesjs.init({
// ...
pluginsOpts: {
"gjs-blocks-basic": {
stylePrefix: '', // no gjs- prefix
flexGrid: 1 // use flexbox instead of tables
}
},
// ...
});
This will probably also fix your previous alignment issues and is much better for responsive design
@theSC0RP This is not really a problem with GrapesJS itself. The cell in GrapesJS has
display:table-cell;
property, so it tries to simulate a table layout, as far as I'm aware. So if you want to change the positioning, then find a way to vertically change position in a table.
One solution might be
vertical-align:middle;
See https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align
So you would either automatically apply this on your custom component or you could create a custom style property for this setting, so that you could easily change it. There might be other ways to align item in a table layout. Alternatively, you can also create your own custom layout component, which can behave as you would like it.
@MartinPutz Thank you for the answer. How would I create and apply a custom style property on the cell? I am using the grapesjs-blocks-basic plugin so the cell has a class name of 'gjs-cell'. I tried to add the suggested property on this class in my styles file but the problem is still there.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3389
MultiSelect some elements and change styles only work on the last selected element
Hi, when I MultiSelect some elements using shift, and change style in styleManager. Only the last clicked element will update the style. Ca...
Issue #3825
BUG: ckeditor wrap and block the text below
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link https:// Des...
Issue #2547
Unable to drag an element if style has bottom or right values
Hi @artf , If any component CSS has bottom or right values , not able to drag them. Values are generating as NaN. Attached the screenshot f...
Issue #3076
QUESTION: Set component's empty state
Hi @artf , How would you recommend giving a component an empty state? Say, for instance, I have a layout component (ie. a column) which sho...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.