How can I keep the initial value of fit-content?

Viewed 59

Is it possible to keep the initial value of a CSS property when it is set to fit-content for example? (or anything that adjusts to the content)

For illustration:

.example{
    width: 100px;
    height: fit-content;
}

I want the height to be only set once in the beginning to fit all the content, but then it should not adjust when child elements change (i want it to behave like a constant pixel/percent value):

.example{
    width: 100px;
    height: getInitialValue(fit-content); 
    /* height should be a constant value and not change by itself */
}



I know that it is possible to implement this behaviour with Javascript and I could also do that, but it would be much cleaner to do it in pure CSS.

Thank you for your help and suggestions in advance!

0 Answers
Related