CSS: position = fixed and height = auto

I have a page with a fixed scroll position for the title. Like the top menu of StackOverflow.

I need to use height = auto, because I can display information in one or more lines. If I used two or more lines than my heading, it appears above the body of the page.

I can solve this problem with a JS script by setting the size of the body-top = header field.

How can I solve this situation only in CSS without JS?

+4
source share
1 answer

I do not think that this can be done exclusively with CSS. Elements with position: fixed are derived from the normal page flow, so they are not used when calculating the position of other elements on the page.

I assume that you could display two headers, one with position: fixed and the other without such an ad (and possibly with "active" page elements such as links, input fields or buttons replaced with static text) that are only used to move other page elements down. That would be a terrible hack, though.

+1
source

All Articles