I have a form that I divided into header, body, and footer, so I want to add a scroll bar on my form that will ONLY control the body and the footer, not the header or navigation.
Loading
I have a form that I divided into header, body, and footer, so I want to add a scroll bar on my form that will ONLY control the body and the footer, not the header or navigation.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhishek YadavPosted Feb 8, 2024, 12:23 PM
To add a vertical scroll bar to your form that only controls the body and footer, you can follow these steps:
Wrap the body and footer sections of your form content inside a div element. Give this div a class or id for easier styling and identification. For example, you can use or .
-
-
Apply a CSS style to the content div to limit its height and enable overflow scrolling. This will create a fixed height container for the body and footer sections, and the scroll bar will appear only when the content exceeds this height. For example, you can use the following CSS:
Make sure to adjust the height value according to the desired height for your content.
Place your header and navigation elements outside the content div so that they remain separate and unaffected by the scroll bar. Ensure that they are positioned correctly within your form structure.
Here's an example of how you can organize your form with a vertical scroll bar that affects only the body and footer:
By applying the CSS style to the content div as shown above, the scroll bar will only appear within the defined height of the content div, while keeping the header and navigation sections outside of it.
Yogi SPosted Feb 8, 2024, 5:13 AM
use overflow:auto in css.
Jignesh KumarPosted Feb 6, 2024, 1:50 AM
Hello Kgaugeli,
Please use this one,
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_sticky_header