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

A margin-top style on a sub-element clips the element #428

Open
Fil opened this issue Aug 31, 2023 · 1 comment
Open

A margin-top style on a sub-element clips the element #428

Fil opened this issue Aug 31, 2023 · 1 comment
Labels

Comments

@Fil
Copy link

Fil commented Aug 31, 2023

Expected Behavior

<div id="zone">
      <div>
        <hr style="margin-top: 1em">
        <h3>Here’s the thing:</h3>
        <p>This part will be clipped!</p>
      </div>
</div>

<button onclick="htmlToImage.toCanvas(document.getElementById('zone')).then((canvas) => document.body.appendChild(canvas));">To image</button>

The paragraph should be part of the generated image

Current Behavior

The paragraph is clipped, because of the margin-top on the hr, which shifts the whole image down.

Possible Solution

I haven't found a good solution, so I'm scouring the tree for any margin-top and if there is one, I add a div at the bottom of the element with a mix-height of 0.1px.

Steps To Reproduce

See above.

Additional Context

here's the result I'm seeing:
image

Your Environment

@Fil Fil added the bug label Aug 31, 2023
@vivcat
Copy link
Contributor

vivcat bot commented Aug 31, 2023

👋 @Fil

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant