# Full Screen CSS Modal

**URL:** <https://forum.freecodecamp.org/t/full-screen-css-modal/732083>\
**Category:** Curriculum Help\
**Created:** [January 27, 2025, 8:30pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083 "2025-01-27T20:30:11Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [January 29, 2025, 12:43am UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/21 "2025-01-29T00:43:11Z")

</div>

The times that I removed 100% width, the modal only shows on mobile in the horizontal middle of screen centered. I’ll test more soon. How can I add (#modal-toggle-2) to the above javascript? 🕶

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [January 29, 2025, 2:08am UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/22 "2025-01-29T02:08:01Z")

</div>

In the dialog CSS, without overflow-y auto, or scroll, the text / image modal Doesn’t scroll. The Only other overflow in the modal CSS is below. That helps to show only the modal scroll bar. 😀

```auto
.stop-scroll {
  overflow: hidden;
}

```

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [January 29, 2025, 3:10pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/23 "2025-01-29T15:10:16Z")

</div>

How can I add (#modal-toggle-2) to the above javascript? 🕶

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [January 31, 2025, 8:17pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/24 "2025-01-31T20:17:14Z")

</div>

I re did that modal. I finally found CSS that hides the body scrollbar when the modals are open! The body is even hidden when modals are open, and the page actually scrolls when the modals are closed! 🕶

```auto
html,
body {
  /* Firefox */
  scrollbar-width: none;
  /* IE 10+ */
  -ms-overflow-style: none;
}

/* WebKit - Safari, Chrome, Opera */
body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

```

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [January 31, 2025, 8:23pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/25 "2025-01-31T20:23:14Z")

</div>

I like the way the modals open / close, scroll, etc.! However, with one page smooth scroll templates, I’d rather Cover the Fixed Header so visitors Don’t scroll the page when the modals are still open. How can the modals Cover the Fixed Header? Thanks! 🕶

Code Pen . io /FavorMan/pen/raBPbyL

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [January 31, 2025, 8:51pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/26 "2025-01-31T20:51:08Z")

</div>

I Moved the modal (z-index) from (.arc-modals .modal-dialog) to (.arc-modals .modal-dialog:target). Now I Finally have Great full screen modals! 🕶

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [January 31, 2025, 10:43pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/27 "2025-01-31T22:43:13Z")

</div>

Actually, on CodePen, the modals Fully Covers the whole body. However, on my editing site, the fixed header still shows. I’m sure that somebody has the solution! 🕶

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [February 4, 2025, 10:25pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/28 "2025-02-04T22:25:55Z")

</div>

Check out my Newest thread. That has a Different code. I’m Near to what I want! 🕶

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [February 4, 2025, 10:26pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/29 "2025-02-04T22:26:32Z")

</div>

Check out my Newest thread. I’m Near to what I want! 🕶

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [February 4, 2025, 10:27pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/30 "2025-02-04T22:27:01Z")

</div>

Please one make one thread per project

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [February 5, 2025, 1:10am UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/31 "2025-02-05T01:10:38Z")

</div>

I created a pen with one of the templates that the modal Doesn’t cover the page fixed navbar. The menu Doesn’t run properly on C P. However, the pen should help people on here figure out how I can get the modal to cover that fixed navbar. 🕶

CodePen .io /FavorMan/ pen/ yyBWOva

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [February 5, 2025, 5:47pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/32 "2025-02-05T17:47:14Z")

</div>

I wouldn’t suggest creating your modals the way you are, it is bound to cause issues. I’m sure you can find tons of modal examples that use very little JS. Use the dialog element and buttons. Add some JS to handle the interactions.

* * *

You have to be mindful of the source order and what elements are parents, siblings, and children. The parent of the modal is the sibling of the fix nav that is on top of it, so that element needs a higher z-index or the nav should have a lower.

Without changing the structure, using the `:has()` selector should work.

```auto
body:has(.modal-dialog:target) .navigation-bar {
  z-index: 0;
}

```

Or targeting the parent

```auto
body:has(.modal-dialog:target) #page-hero {
  position: relative;
  z-index: 10;
}

```

Your modal close button shouldn’t be full width, otherwise it will cover the modal content when you scroll. Remove the `left` and `width` properties from its selector.

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [February 5, 2025, 9:30pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/33 "2025-02-05T21:30:40Z")

</div>

Thanks lasjorg! The 2 body:has CSS helped the modals to cover the page fixed header! I plan to use top one. I’m seeing a (Expected RPAREN Error). How can I Remove that Error?

Should I keep the 2 other z-index that I already had?

Do you know how I can Prevent the page from showing after the modal is done scrolling?

Also, due to the fix, I changed the shut button to (top: 0). 🕶

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [February 6, 2025, 7:19pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/34 "2025-02-06T19:19:46Z")

</div>

1. I don’t know what that error is, but the browser must support the `:has()` selector and it is fairly new.

2. Not really, if the nav has 0 for its z-index the modal is after it in the source order so it should be on top of it. But it doesn’t hurt to have it unless it is interfering with something else.

3. Add `overscroll-behavior: contain;` to `.modal-dialog`

4. But it is still full width, which makes it cover the content when you scroll.

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [February 6, 2025, 7:51pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/35 "2025-02-06T19:51:40Z")

</div>

I want the (X) to stay Fixed on top. 🙂

overscroll-behavior: contain; Stopped the body from showing when the modals are open! On a Different template, there was also sticky like activity that showed on top of the shut bar when modal scrolling. That’s also Solved! Thanks! 🕶

Any idea how I can get the navbar menu to open on CodePen? 🕶

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [February 6, 2025, 8:04pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/36 "2025-02-06T20:04:44Z")

</div>

A close button should be the size of its content, which is just an X in this case. I don’t know why you would want it to cover the modal content when the modal is scrolled.

I assume there is some JavaScript code missing for the nav.

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [February 6, 2025, 8:11pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/37 "2025-02-06T20:11:23Z")

</div>

What I have is likely foreign to CodePen. I made the fixed (X) area 25px. So, that Doesn’t take a lot of room.

CodePen is fussy about having “actual” links.

```auto
<li class="menu-item has-submenu-OFF"><a tabindex="0">ABOUT US +</a>

```

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [February 6, 2025, 8:18pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/38 "2025-02-06T20:18:09Z")

</div>

The smaller screens navbar Doesn’t fully close when smooth scrolling. I looked up a Number of scripts to help. No success yet. 😀

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [February 6, 2025, 9:04pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/39 "2025-02-06T21:04:15Z")

</div>

Actually, on Firefox, the other template is showing the modals as in the screenshot on windows and android. Otherwise, I Like this.  
🕶

 ![Firefox-Header](https://global.discourse-cdn.com/freecodecamp/original/4X/d/4/7/d47ed731e523775562555ead57232f28658496e2.png)

---

<div class="post-metadata">

**Author:** ![FavorMan](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@FavorMan](https://forum.freecodecamp.org/u/FavorMan)\
**Post date:** [February 6, 2025, 10:15pm UTC](https://forum.freecodecamp.org/t/full-screen-css-modal/732083/40 "2025-02-06T22:15:16Z")

</div>

Now I noticed that Brave mobile also shows some of the page header on top of the modals. 🙃

[Previous page](https://forum.freecodecamp.org/t/full-screen-css-modal/732083.md?page=1)

[Next page](https://forum.freecodecamp.org/t/full-screen-css-modal/732083.md?page=3)
