Issue #3085Opened October 21, 2020by theSC0RP6 reactions

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.

Screenshot (175)

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

Answers (3)

Ju99ernautOctober 23, 20206 reactions

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

MartinPutzOctober 21, 20200 reactions

@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.

theSC0RPOctober 22, 20200 reactions

@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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.