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

Canvas expands when inside a CSS grid #2447

Closed
petargyurov opened this issue Aug 19, 2022 · 4 comments
Closed

Canvas expands when inside a CSS grid #2447

petargyurov opened this issue Aug 19, 2022 · 4 comments
Labels
bug Something isn't working dependencies An upstream issue to do with dependencies

Comments

@petargyurov
Copy link

My page has a basic CSS grid layout. It's responsive, so each panel changes as the size of the parent changes. See video below:

Screen.Recording.2022-08-19.at.13.32.56.mov

When I replace the C panel with a basic <Canvas> element, the panel starts off with a certain width but immediately expands to some unknown value. In addition, the responsiveness is broken.

Screen.Recording.2022-08-19.at.13.36.03.mov

I cannot for the life of me figure out why this is happening. I have tried modifying the size of the parent div. I have tried setting a manual width to the canvas which also appears to break things further.

How do I make the canvas respect the initial size of its panel? How do I make the canvas responsive?

Is this a bug or something wrong with my CSS?

👉 Code Sandbox

@Yasha-ops
Copy link

I have the same probleme... Can someone explain ?

@chuhongkyu
Copy link

docs - https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html

This is often the case when dealing with canvas. You may have to solve it with JavaScript instead of css.

If it's a cnavas without a background in the model,
Fix the canvas to the center in the grid-column and use it.

This is my old project screen.

ezgif com-gif-maker

I hope it helps you.

@CodyJasonBennett CodyJasonBennett added bug Something isn't working dependencies An upstream issue to do with dependencies labels Sep 3, 2022
@dahuigeniu
Copy link

good thankyou

@rockandsalt
Copy link

I ended up finding an alternative solution. css grid are by default not allowed to shrink below the content size.. By setting min-height and min-width to 0 on the parent div of the canvas. The canvas will shrink correctly.

@CodyJasonBennett CodyJasonBennett closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies An upstream issue to do with dependencies
Projects
None yet
Development

No branches or pull requests

6 participants