-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
Avoid vertical space with backend_show
#3642
Conversation
I'm not really knowledgeable enough about CSS and HTML to know if this is the "right" solution, but if it has a better result in more frontends that's fine with me. I had thought that width and height of the img tag communicated the intended size of the image, but that it could still be scaled depending on its placement in a container div. I had chosen these settings at the time because the VSCode plot pane had some max-width setting or so that squished the image under certain circumstances. If height auto fixes that as well, we might be able to remove the |
Yes and I think your observation that Below is an example from PlutoStaticHTML.jl. I've tested the patch for Pluto.jl too, but not with VSCode as I don't have that installed. ExampleHere is an example from https://huijzer.xyz/posts/latent/. The width of this page is restricted to 705 px on desktop screens via the When I change the settings, I see the following (see which settings are enabled/disabled in the bottom of the images). Figure 1: Squished aspect ratioFigure 2: Too much vertical spaceFigure 3: Correct |
|
Thanks for updating the CHANGELOG for me and for accepting this patch, @jkrumbiegel 🙂 |
thank you! |
Description
When using CairoMakie in Pluto.jl, a lot of whitespace is in some cases shown above and below the Makie images. For example, when plotting
with Makie
v0.11.8
, the output looks as follows:The root cause for this seems to be that Makie generates the following HTML:
Here, it makes sense that the
width
andheight
are set explicitly because that metadata cannot be set in the base64 encoded image if I'm not mistaken. Next, theobject-fit: contain;
causes the image to always retain the original aspect ratio by rescaling the image width or height when needed. However,object-fit: contain
will not automatically rescale the HTML element width or height when needed. Instead, those remain fixed and the object will be "letterboxed" (more information at the Mozilla docs). In the example image, for example, the height remains 600 even though the image height is rescaled to 291.This PR suggests to fix that by setting
height: auto
in the style. This tells the browser that the height of the containing element can be rescaled if needed. I've tested this withPluto.jl
andPlutoStaticHTML.jl
and in both cases this will avoid the vertical space.Type of change
Checklist