i decided to go with fixed position. Seems less sloppy than a panel which can appear in various spots, or get scrolled out of view.
Some issues:
Close X
- The close-X doesn’t always appear at upper right corner – sometimes it falls off to the right. I shrink panel width on narrow screens using the following:
max-width: 600px;
width: 70vw;
The X position should adapt to changing panel size, and any browser-zoom. I attempted to fix with the following, but not quite working at certain in-between widths.
.linker:focus + .closer {
left: min( 90vw , 700px );
}
This method seems like a poor way to approximate the correct position. It seems the close-X should be somehow positioned relative to the upper-right of the panel, so it will stick there no matter where the panel appears or what panel-width. A challenge is that the closer <a>
cannot go inside the linker <a>
, because a
tags aren’t permitted to contain other a
tags. So the linker and closer are siblings. The structure is (these are class-names of the divs):
<box>
<linker />
<closer />
<box/>
linker
switches to position: fixed
when the panel is displayed. If the closer remains inline or relative, then it won’t move to the panel – it will stay in the grid.
Better might be something like left
and max-left
, but there’s no such thing as “max-left”.
Currently, the linker IS the panel, by changing it’s position to fixed. Maybe i need to contain the closer and linker together by positioning them inside an extra container. Something like this?
<box> grid placeholder
<panel>
<linker>
<closer>
</panel>
</box>
The challenge with that is we need to style panel
when linker
gets focus (due to mouse-click). We could use this:
panel:hasfocus
The problem is that the closer is also a link. The above hasfocus would detect when the linker is clicked (which we want), but will also detect when the closer is clicked (which we don’t want).
I think the solution should look something like this, but this isn’t working.
.box:has(linker:focused) .linker {
https://ishadeed.com/article/css-has-parent-selector
It may be preferable if the entire panel can be clicked to close it. I don’t know if that simplifies.
Panel Fadeout
- It would be great if panel could fade-out when closing, but can’t figure how, without affecting the element in the grid. I think it has to be something like:
.box:has(closer:focused) .linker {animation-fadeOut}
Jump Up
When content is too tall to fit on one screen, clicking a grid-element near the bottom of the grid causes the page to scroll up. I guess that’s because the page is scrolling to the panel, but that doesn’t make sense since the panel is fixed-positioned, so it should be treated as if it’s on the visible area of the page.
Image Cross-fade
- It would be great if the image could cross-fade going from grid to panel, but i guess that’s impossible since it’s the same image!