> For the complete documentation index, see [llms.txt](https://docs.realmacsoftware.com/elements-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.realmacsoftware.com/elements-docs/getting-started/how-to/build-a-sticky-menu.md).

# Build a Sticky Menu

To make a menu sticky, you need to put the menu and all contents in a container (site wrapper) along with making the following changes to the menu settings:

Layout > Position set to Sticky.

Layout > Z-Index > Custom set to 100.

Layout > Type > Uniform > Inset 0.

Watch the following tutorial to see how to build a Sticky Menu, along with adding a drop shadow and frosted glass effect.

{% embed url="<https://youtu.be/E7lQCiPmuQo>" %}

## Advanced Sticky Menu Tutorial - Part 2

In this advanced tutorial we use some Javascript to adjust the look of the menu when the user scrolls down the page.

You can [click here to open the Space Demo Project](elementsapp://downloadDocument/sDsH9PgNy9uG) in Elements.

{% embed url="<https://youtu.be/Wv7J6BpHoEA>" %}

### Code Examples

Adding and Removing Standard CSS Classes:

```javascript
<script>
	const menu = document.getElementById('fancymenu');
	window.addEventListener('scroll', () => {
	  if (window.scrollY > 800) {
		menu.style.setProperty("width", "100%");
		menu.style.setProperty("height", "80px");
		menu.style.setProperty("margin-top", "0");
		menu.style.setProperty("background", "#ffffff");
	  } else {
		menu.style.removeProperty("width");
		menu.style.removeProperty("height");
		menu.style.removeProperty("margin-top");
		menu.style.removeProperty("background");
	  }
	});
</script>
```

Adding and Removing Tailwind Classes:

```javascript

	<script>
	const menu = document.getElementById('fancymenu');
	window.addEventListener('scroll', () => {
	  if (window.scrollY > 500) {
		menu.classList.add('w-auto');
		menu.classList.remove('w-[1000px]', 'mt-10');
	  } else {
		menu.classList.add('w-[1000px]', 'mt-10');
		menu.classList.remove('w-auto');
	  }
	});
 </script>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.realmacsoftware.com/elements-docs/getting-started/how-to/build-a-sticky-menu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
