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

Handle absolute children of flex boxes #996

Closed
daniel-butler opened this issue Nov 19, 2019 · 4 comments
Closed

Handle absolute children of flex boxes #996

daniel-butler opened this issue Nov 19, 2019 · 4 comments
Labels
bug Existing features not working as expected
Milestone

Comments

@daniel-butler
Copy link

Thank you for the amazing project! Because of this project I only have the problem below

Are there any gotcha's with position: absolute? I have not been able to get it to work. I was able to get bootstrap.css working with the pdf, but elements with the style of position absolute do not get rendered.

This is the custom css file

div div#payment_method {
     position: absolute;
     font-weight: bolder;
     opacity: 80%;
     color: #3e1052;
}

..and the html

<div class="row justify-content-center">
  <div
    id="payment_method"
    class="display-2"
  >
    <i>Paid by EFT</i>
</div>

The payment_method id is not rendered if position: absolute is displayed once I remove it the element is displayed, but the element is inline.

@Tontyna
Copy link
Contributor

Tontyna commented Nov 19, 2019

Reason for absolute box not being displayed is that the row is a flex container (display:flex). This is by purpose or at least it's explicitly programmed. An absolutely positioned box is never a flex item:

if not child.is_absolutely_positioned():
child.is_flex_item = True

In flex_layout() children of a FlexBox not being flex items are skipped and disappear from the output:

for child in children:
if not child.is_flex_item:
continue

Of course: Absolute boxes aren't part of the flex layout, but instead of disappearing they should be handled as described in the spec.

Until implemented (in version 52?) a "WARNING: ignored absolutely-positioned flex child. Will be implemented in the future" would be nice or at least a # TODO in the source code.

@daniel-butler
Copy link
Author

Thank you for the quick and through response!

Just to summarize what seems to be the issue. The reason this doesn't work is because bootstrap v4 uses display: flex. Weasyprint does not allow absolute positioned items in a flex element/container?

Using @Tontyna's explanation I used absolute positioning inherent in bootstrap by adding the class position-absolute to the row element.

@Tontyna
Copy link
Contributor

Tontyna commented Nov 19, 2019

Weasyprint does not allow absolute positioned items in a flex element/container?

Exactly.

@liZe liZe changed the title position: absolute Handle absolute children of flex boxes Nov 25, 2019
@liZe liZe added the bug Existing features not working as expected label Nov 25, 2019
@liZe liZe added this to the 56.0 milestone Dec 11, 2021
@grewn0uille grewn0uille modified the milestones: 57.0, 58.0 Jul 13, 2022
@alberto255345
Copy link

Is there any possibility for me to enable "Position: Absolute"? because I have a project that I can't imagine another way to do without "Absolute".

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

No branches or pull requests

5 participants