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.
Jignesh KumarRank #91 · 22.9K reputationPosted Feb 5, 2024, 8:50 PM EST
Hello Kgaugeli,
Please use this one,
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_sticky_header
Abhishek YadavRank #217 · 11.3K reputationPosted Feb 8, 2024, 7:23 AM EST
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 .
-
CSS
-
Code
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:
.content { height: 400px; /* adjust the height as per your requirement */ overflow-y: auto; }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 SRank #511 · 4.8K reputationPosted Feb 8, 2024, 12:13 AM EST
use overflow:auto in css.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts