Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add container divs for each column in the Columns block #5935

Closed
paulwilde opened this issue Apr 2, 2018 · 4 comments
Closed

Add container divs for each column in the Columns block #5935

paulwilde opened this issue Apr 2, 2018 · 4 comments
Labels
[Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P

Comments

@paulwilde
Copy link
Contributor

paulwilde commented Apr 2, 2018

The current way that the columns HTML is saved makes it impossible to style if you aren't using CSS Grid. Whist browser support for CSS Grid is decent, it's not good enough when dealing with particular clients (An example being the NHS in the UK).

For a 2 column block, the current output is as such:

<div class="wp-block-columns has-2-columns">
    <p class="layout-column-1">Column 1</p>
    <figure class="wp-block-image layout-column-1"><img src=""></figure>
    <p class="layout-column-2">Second one</p>
</div>

To allow for a grid using CSS Flexbox, or legacy floats it would need to be:

<div class="wp-block-columns has-2-columns">
    <div class="column layout-column-1">
        <p>Column 1</p>
        <figure class="wp-block-image"><img src=""></figure>
    </div>
    <div class="column layout-column-2">
        <p>Second one</p>
    </div>
</div>

Adding containers still works with CSS Grid, whilst also allowing for added flexibility. Having the added column class also allows for much more flexibility (Instead of targeting layout-column-1, layout-column-2 etc.) such as the following CSS:

.wp-block-columns {
    display: flex;
    flex: flex-wrap;
}

.has-2-columns > .column {
    flex: 0 0 50%;
}
@paulwilde
Copy link
Contributor Author

paulwilde commented Apr 2, 2018

Upon further testing it seems that the current implementation has bugs with what I'm trying to achieve anyway, so if anything this is required moving forward regardless.

In the Gutenberg admin here is the Columns block with 2 columns, text with right floated images:
screen shot 2018-04-03 at 00 23 38

Now on the front-end (Using identical grid markup as Gutenberg), this is how its displayed:
screen shot 2018-04-03 at 00 24 57

Due to the lack of containers, the image isn't contained. This isn't an issue within Gutenberg itself due to markup actually having containing divs:

screen shot 2018-04-03 at 00 28 22

@samikeijonen
Copy link
Contributor

Discussion also in #5351.

@rchipka
Copy link

rchipka commented May 9, 2018

👍

@paulwilde
Copy link
Contributor Author

#7234 resolved this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P
Projects
None yet
Development

No branches or pull requests

5 participants