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

Nested flexbox doesn't render correctly #1171

Closed
zelitomas opened this issue Jul 22, 2020 · 15 comments · Fixed by #2231
Closed

Nested flexbox doesn't render correctly #1171

zelitomas opened this issue Jul 22, 2020 · 15 comments · Fixed by #2231
Labels
bug Existing features not working as expected
Milestone

Comments

@zelitomas
Copy link

Hi,

I have encountered a problem with nested flexbox that I can't figure out how to solve. If I use simple flexbox, everything works as expected, but when I try to nest them, strange things starts to happens.

Here is the most simplified example I could come up with:

    #paper {
        width: 148mm;
        height: 105mm;
        
        display: flex;
        flex-direction: column;
    }
    #content {
        width: 100%;

        display: flex;
        flex-direction: column;
        flex: auto;
        justify-content: space-between;
    }
    #header {
        width: 100%;
        height: 2cm;
    }
<div id="paper">
    <div id="header" style="background-color:lightblue">Header part, should be full width, 2 cm height</div>

    <div id="content">
        <div style="background-color:orange" class="toppart">
            Middle part, should be 100% width, blank space should follow thanks to justify-items: between.
        </div>
        <div class="bottompart" style="background-color:yellow">
            Bottom part. Should be 100% width, blank space before.
        </div>                
    </div>
    
    
</div>

The expected result should look something like this:

Snímek z 2020-07-23 01-50-50

But the actual result looks like this:

Snímek z 2020-07-23 01-55-08

I couldn't find similar bug, so I'm reporting it here, sorry if it is a duplicate. Is there anything I could do to help fix this issue?

@kingraphaii
Copy link

Having same issue here, version 51. Did you find a work around?

@zelitomas
Copy link
Author

Unfortunately, I have not. And I'm not fluent enough in python to find the bug in the code, unfortunately.

@liZe liZe added the bug Existing features not working as expected label Jul 29, 2020
@zelitomas
Copy link
Author

zelitomas commented Aug 30, 2020

Hi, Is there any way I could help resolving this issue?

(adding more examples, etc)

@liZe
Copy link
Member

liZe commented Oct 21, 2020

Hi, Is there any way I could help resolving this issue?

(adding more examples, etc)

I just need more time to fix this issue 🕐. The examples are really useful, thank you!

@sharicahill
Copy link

Hi, sorry for opening a new issue. I'll keep my comments in this one.

I've found a workaround for the width issue in case anyone else has the same problem. Not sure about the justify-content: space-between; issue with the blank space in the first example.

I think the issue with the widths is related to the percentages on the child elements. If you replace the percentages with fixed values, eg. width: 100px; it renders correctly. Using the flex property on the child elements also works, eg. flex: 1;

@liZe
Copy link
Member

liZe commented Oct 5, 2021

I think the issue with the widths is related to the percentages on the child elements.

Then it’s probably related to #656 too.

Hi, sorry for opening a new issue.

No problem, thanks for the bug report! It’s always useful to get different examples when there’s an issue.

@serbboy23
Copy link

Hello,
I'm also seeing this issue and have tested with version 54.0b1. The elements within my nested flexbox are not filling the width of my parent.
As @sharicahill mentioned, the only workaround is to manually set the with of my elements .. however this is not ideal as some of my elements are dynamic is size.

@micycle1
Copy link

micycle1 commented Jan 31, 2022

Another (simple) example, I believe:

HTML+CSS

Expected layout
image

WeasyPrint PDF

WeasyPrint layout
image

@page {
    margin: 1em;
}

article {
    display: flex;
    flex-direction: column;
    max-height: 297mm;
    max-width: 210mm;
    align-content: center;
    margin: 3em 2em;
}

img {
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
    min-width: 0;
    object-fit: contain;
}

article div {
    display: flex;
}
<html>

<head>
    <meta charset="utf-8">
    <link href="columns-test.css" rel="stylesheet">
    <title>test</title>
    <meta name="description" content="Report example">
</head>

<body>
    <article>
        <img src="figures/a.jpg">
        <img src="figures/a.jpg">
        <img src="figures/a.jpg">
        <div>
            <img src="figures/a.jpg">
            <img src="figures/a.jpg">
        </div>
    </article>
</body>

</html>

Adding the following doesn't help PDF output much either.

article div {
    width: 200px;
    height: 200px;
}

image


Swapping out the nested flexbox for a grid doesn't render as expected too:

article div {
    display: grid;
    grid-template-columns: 50% 50%;
    grid-template-rows: 100%;
}

HTML+CSS

image

WeasyPrint PDF

image

@ankitpandeypagefreezer
Copy link

Please fix this issue.

@liZe
Copy link
Member

liZe commented May 16, 2023

Please fix this issue.

Hi!

As maintainers, we’d also love to see this issue fixed. But…

Getting a proper flexbox rendering is long and complicated, and we currently don’t have enough free time to do this right now. The three main solutions you have to get this issue fixed is:

  • To wait for the maintainers to spend their free time to work on this. As it’s long and complicated, it may not happen soon.
  • To open a pull request.
  • To pay someone (for example the maintainers) to fix this.

@vesters
Copy link

vesters commented Dec 15, 2023

Hi liZe

Thank you very much for your reply. I could be really nice to get some flexbox support for this lovely piece of software.

What amount you estimate would be enough to get this done within a couple of monts maybe?

@liZe
Copy link
Member

liZe commented Dec 18, 2023

Hi @vesters,

We think that it would take between 1 and 2 weeks full time to get a solid implementation. It’s not that long, but it’s still too long to work seriously on this on our free time.

@vesters
Copy link

vesters commented Dec 28, 2023

@liZe Thank you for getting back to me on this.

It sounds reasonable - do you guys have a going hourly rate?

@liZe
Copy link
Member

liZe commented Jan 3, 2024

It sounds reasonable - do you guys have a going hourly rate?

@vesters Let’s discuss about this by mail! You can reach us at contact@courtbouillon.org.

@onedapperterm
Copy link

At this date the issue is not yet fixed (V61.2), but a workaround is using tables, and yes, is a pain in the neck, but depending on the case it works fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants