Problem with element positioning in a multi-column layout
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.

@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.
Hi, @artf. A few observations after experimenting on the demo website and comparing the results with my grapesjs-blocks-basic implementation
- The 'display' attribute of the row element in the styles panel on the demo page is set to flex by default. That is not the case when I am using the blocks basic library. I am getting the default 'display' attribute as blank
- Similarly the 'display' attribute of the cell element is 'block' but it is blank in my implementation.
- The class names of row and cell on the demo page are row and cell respectively but in the grapesjs-blocks-basic the class names are 'gjs-row' and 'gjs-cell' respectively.
Are the above things supposed to be that way?
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
@Ju99ernaut Thank you so much. That works like a charm and it has solved both the problems.