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

Problems with layout: two_cols-header #1510

Open
KerstinKeller opened this issue Apr 9, 2024 · 5 comments
Open

Problems with layout: two_cols-header #1510

KerstinKeller opened this issue Apr 9, 2024 · 5 comments
Labels
enhancement New feature or request has workaround

Comments

@KerstinKeller
Copy link

Describe the bug
I am having some trouble using the layout: two-cols-header.
When using this layout, the start of the columns seem to be aligned in the the middle of the slide, rather then starting below the common text.
Take this example:

---
layout: two-cols-header
---
This spans both
::left::
# Left
This shows on the left
- albc
- aegaw
- badf
- baer
- abewb
- abe
- abweawb
::right::
# Right
This shows on the right
::bottom::
This shows at the bottom, aligned to the end (bottom) of the grid

Renders as

image

When you want to put some code, it's even worse:
image

What can be done to move up the columns? I guess packages/client/layouts/two-cols-header.vue has to be modified somehow?

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Edge
  • Slidev version: latest (0.48.8)
@KerstinKeller
Copy link
Author

KerstinKeller commented Apr 9, 2024

Chatgpt suggests the following changes to two-cols-header.vue which actually gives a pleasing result:

Here's a suggestion to adjust your grid to include three explicit rows:

.two-cols-header {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: auto 1fr auto; /* Adjust to fit content */
}

/* Adjust other styles as necessary to fit the new grid definition */
.col-bottom {
  align-self: end;
  grid-area: 3 / 1 / 4 / 3; /* Adjust this to correctly place the bottom area */
}

This adjustment defines the grid with three rows: one for the header (auto to size based on content), a flexible middle row (1fr), and another auto row for the bottom content. Adjusting .col-bottom to start from the third row ensures it's placed at the bottom of the grid, potentially solving the layout issue you're experiencing.

It does give a more pleasing outcome:
image

Should I create a PR for this? Or do you have other suggestions?

@KermanX
Copy link
Member

KermanX commented Apr 10, 2024

It might be better if the layout uses flex instead of the static grid. But changing this will break many existing slides.

@draptik
Copy link

draptik commented Apr 11, 2024

@KerstinKeller thanks for sharing the workaround: I stumbled into the same issue today!
Is there an easy css fix to add some padding/margin between the 2 bottom code blocks? My css skills are pretty rusty...

@KerstinKeller
Copy link
Author

I added the following line:

.two-cols-custom {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: auto 1fr auto;
  column-gap: 20px; /* Adjust the gap size as needed */
}

However, I have no clue about web development whatsoever, so I don't know if it's a good or bad way to handle this, however it does work.

@draptik
Copy link

draptik commented Apr 13, 2024

@KerstinKeller Thank you so much - also for the quick response: saved my day!
Worked like a charm, talk went well. 🙏

@KermanX KermanX added enhancement New feature or request has workaround labels Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request has workaround
Projects
None yet
Development

No branches or pull requests

3 participants