Closed havok2063 closed 2 months ago
Hi @havok2063!
I think what you're trying to do is correct, but the comma between the CSS attributes should be replaced by a semicolon.
@iisakkirotko ahh yes thanks. that disabled the scrolling, but it doesn't resize my main content to fit the browser view window.
@havok2063 So you want the content of the topmost solara.Column
to take up all available space? If that's the case, I'd give the content you want to grow flex-grow: 1
(they need to also have display: flex
, and the align-items
or justify-content
properties of the topmost solara.Column
might need to be changed to stretch
. You can find more details here)
@iisakkirotko Yeah either the top solara.Column
(i.e. the entire page content) or the bottom solara.Column
component. But your suggestion didn't work for me. I'm wondering if there's a css conflict or overriding happening with the any of the children pieces. Do you have a working example?
@havok2063 That's interesting, since this seems to work fine for me (I did add flex-grow: 0;
to the solara.Columns
element, which I forgot to mention)
import solara
all_files = ["a", "b", "c"]
files = solara.reactive([all_files[0]])
@solara.component
def Page():
with solara.Column(style="height: 100vh; overflow: hidden;"):
solara.Title("Spectral Display")
css = """
main.v-content.solara-content-main {
padding: 0px !important;
}
"""
solara.Style(css)
with solara.Columns([1, 0, 1], style="margin: 0 5px; flex-grow: 0;"):
with solara.Tooltip("Select the spectral files to load"):
solara.SelectMultiple("Data Files", files, all_files, dense=True)
solara.Button("Load data", color="primary")
with solara.FileDownload("solara-lazy-download.txt"):
with solara.Tooltip(
"Download a Jdaviz Jupyter notebook for these data"
):
solara.Button(label="Download Jupyter notebook", color="primary")
solara.Column(style="overflow: hidden; flex-grow: 1; background-color: red;")
Could maybe be a style collision with something from jdaviz, since I don't have any of those elements in my version?
@iisakkirotko there very well could be a style collision with jdaviz, however I can recreate it with an image. If I replace your last Column with
with solara.Column(style="overflow: hidden; flex-grow: 1; background-color: red; height: 100vh;"):
image_url = "https://picsum.photos/500"
solara.Image(image_url, width='100vw')
display(image_url)
the image fills the full viewer width but not the viewer height. The scrolling is turned off so it's cutoff. If I remove the style from both solara.Column
pieces then I can see the full image by scrolling vertically. I figured the height: 100vh
would make the image fill the browser viewport?
@havok2063 After looking at this for way too long, I think I've finally figured the solution:
import solara
all_files = ["a", "b", "c"]
files = solara.reactive([all_files[0]])
@solara.component
def Page():
with solara.Column(style="height: 100vh; width: calc(100vw - (100vw - 100%));"):
solara.Title("Spectral Display")
css = """
main.v-content.solara-content-main {
padding: 0px !important;
}
"""
solara.Style(css)
with solara.Columns(
[1, 0, 1], style="padding: 0 5px; flex: 0 1 auto; margin:0;"
):
with solara.Tooltip("Select the spectral files to load"):
solara.SelectMultiple("Data Files", files, all_files, dense=True)
solara.Button("Load data", color="primary")
with solara.FileDownload("solara-lazy-download.txt"):
with solara.Tooltip(
"Download a Jdaviz Jupyter notebook for these data"
):
solara.Button(label="Download Jupyter notebook", color="primary")
with solara.Column(
style="justify-content: stretch; flex: 1 1 0; min-height: 0; background-color: red;"
):
image_url = "https://picsum.photos/500"
solara.v.Html(
tag="img",
attributes={"src": image_url},
style_="display:flex; flex: 1 1 0; min-height: 0;",
)
height: 100vh;
is fine, as long as nothing additional (like a scroll bar) is there at the bottom of the screen. width: calc(100vw - (100vw - 100%));
, because 100vw
includes the whole viewport, even the (now empty) spot where the usual scrollbar is.overflow: hidden;
on the topmost Column, but this isn't necessary, as long as we have margin: 0;
on Columns (by default the element used to make the Columns, .row
has a margin of -12px
for... reasons)flex: 1 1 0;
for
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0;
together with min-height: 0;
to tell the browser if can make the element as small in height as it wants (images want to scale their height based on their natural aspect ratio) sneaky edit: You can also use height: 100%; width: 100%;
on the image to reach the same result.
Let's hope that this finally works for both of us.
Also, we have improved the scrolling situation in #518 and #477 If there is still an issue with scrolling, please re-open this issue, otherwise we'll assume all is resolved now.
How can I disable scrolling of the main content area and force the content to fill 100% of the view window. I tried adding
style='height: 100vh, overflow: hidden'
to thesolara.Column
but this didn't work.