I want to set my element to be horizontally centered, and do such with
margin-left: auto;
margin-right: auto;
Now I want my vertical offset to be the same as my horizontal offset, except that it caps it out at a certain point, let's say 100px.
My current solution is using calc and min and adding it to the padding:
div {
--width: 80ch;
max-width: var(--width);
/* short hand for margin-[left|right] */
margin-inline: auto;
/* short hand for padding-[bottom|top] */
padding-block: min(100px, calc((100% - var(--width) / 2));
}
This works, and achieves the result I want. Which again, is that I have the same horizontal and vertical offset, up until a point (100px). At that point the horizontal offset still grows as the page width grows, but the vertical offset is capped at 100px.
but I'm wondering if there's a more simple solution.