Home > Article > Web Front-end > How to Prevent a Fixed Top Nav Bar from Obscuring Page Content?
As seen in the provided Twitter Bootstrap code, the fixed top navigation bar obstructs the upper portion of the page's content. To address this issue and ensure that the content becomes visible below the nav bar when the top of the page is viewed, implementing a CSS solution is essential.
The proposed solution consists of applying a padding to the body element with a value of 60px. This places a margin between the top of the page and the nav bar, effectively pushing the content below the nav bar. However, as the Bootstrap framework incorporates responsiveness, an additional media query is utilized.
With the media query, when the screen width falls below 979px, the body element's padding is reset to 0px, preventing the emergence of a gap between the top of the page and the nav bar on smaller screens. This ensures that the content is appropriately presented regardless of the device being used.
The above is the detailed content of How to Prevent a Fixed Top Nav Bar from Obscuring Page Content?. For more information, please follow other related articles on the PHP Chinese website!