Skip to content

how to vertical align only the heading h1 to top. #478

Answered by yhatt
cmaspi asked this question in Q&A
Discussion options

You must be logged in to vote

A simple solution is using absolutely positioning to h1.

style: |
  h1 {
    position: absolute;
    top: 60px;
    left: 75px;
    right: 75px;
  }

Suitable distances for top, left, and right may be different by using theme.

Another solution

The positioning of absolute element is not affected from other elements, so may overlap with slide contents if there are a lot of contents.

For centering in cross axis (vertically in this case) with keeping flex items, sandwich main contents with 2 flex items that has flex-grow: 1. Following style is using h1 and a generated empty content to sandwich.

section > h1 {
  flex: 1 0 auto;
  padding: 0;
  margin: 0;
  order: -999999;
}

section:has(> h1)::b…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cmaspi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants