-
I want to align only the heading to the top but not any other content in the slide. After hours of googling, I found only the following solution
However, this aligns everything. Being a novice in CSS, my natural instinct was to use h1 instead of section. That doesn't appear to solve anything though. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
A simple solution is using absolutely positioning to style: |
h1 {
position: absolute;
top: 60px;
left: 75px;
right: 75px;
} Suitable distances for Another solutionThe 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 section > h1 {
flex: 1 0 auto;
padding: 0;
margin: 0;
order: -999999;
}
section:has(> h1)::before {
flex: 1 0 auto;
display: block;
content: '';
order: 999999;
} |
Beta Was this translation helpful? Give feedback.
A simple solution is using absolutely positioning to
h1
.Suitable distances for
top
,left
, andright
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 usingh1
and a generated empty content to sandwich.