How to fix the menu at a distance of 100px #103242
-
Select Topic AreaQuestion BodyHow to fix the menu at a distance of 100px from the top of the page, if it's more than 100px, it will be hidden( html,css and JS) pls |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Hello @ToitenAn Can you share the image or codes of the menu? |
Beta Was this translation helpful? Give feedback.
-
Define the styles for your menu and content. For the menu, set it to have a fixed position, 100px from the top, with a background color, padding, and z-index to ensure it's always visible. Also, add styles for the menu items (like links). For the content, make sure it has enough padding at the top to prevent it from being covered by the menu. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
HTML (index.html):
/* styles.css */ #fixed-header { #fixed-header nav ul { #fixed-header nav ul li { #fixed-header nav ul li a { // script.js
}); |
Beta Was this translation helpful? Give feedback.
-
Hi @ToitenAn - this issue appears to be resolved per this comment. Could you please confirm and close out this issue? Thank you! (cc @queenofcorgis) |
Beta Was this translation helpful? Give feedback.
HTML (index.html):
<title>Fixed Menu Example</title>Create a new file named index.html and copy the HTML content into it.
/* styles.css */
body {
margin: 0;
padding: 0;
}
#fixed-header {
position: fixed;
top: -100px; /* Initially hide the menu above the viewport /
left: 0;
width: 100%;
background-color: #333; / Choose your background color /
padding: 10px 0; / Adjust padding according to your design /
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); / Optional: Add a subtle …