this is the html

<cat>
         <ul>
            <li><span><a href="#">Sekolah</a></span>
            <ul>
                    <li><a href="perutusan.html">Perutusan Guru Besar</a></li>
                    <li><a href="sejarah.html">Sejarah</a></li>
                    <li><a href="etos.html">Etos</a></li>
                    <li><a href="#">Iklim Sekolah</a>
                        <ul>
                            <li><a href="falsafah.html">Falsafah Misi Visi</a></li>
                            <li><a href="logo&bendera.html">Logo & Bendera</a></li>
                            <li><a href="piagam.html">Piagam</a></li>
                            <li><a href="lagu.html">Lagu</a></li>
                        </ul>
                      </li>  
                    <li><a href="peraturan.html">Peraturan</a></li>
                    <li><a href="pelanevakuasi.html">Pelan Evakuasi</a></li>
                    <li><a href="pelansekolah.html">Pelan Sekolah</a></li>

             </ul>
             </li>
            <li><span><a href="#">Pengurusan</a></span></li>
            <li><span><a href="#">PIBG</a></span></li>
            <li><span><a href="#">BKGS</a></span></li>
            <li><span><a href="#">Pengumuman</a></span></li>
            <li><span><a href="#">Murid</a></span></li>
            <li><span><a href="#">Pencapaian</a></span></li>
            <li><span><a href="#">Kurikulum</a></span></li>
            <li><span><a href="#">Ko-kurikulum</a></span></li>
            <li><span><a href="#">e-SEKOLAH</a></span></li>
            <li><span><a href="#">Rakan Sekolah</a></span></li>
            <li class="last"><span><a href="#">Calendar</a></span></li>
         </ul>
         </cat>

this is the css

cat {
    padding-bottom:37px;
}
 cat {
    margin: 100px auto; 
    text-align: center;
}

cat ul ul {
    display: none;
}

    cat ul li:hover > ul {
        display: block;
    }


cat ul {
    background: #efefef; 
    background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);  
    background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%); 
    background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%); 
    box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
    padding: 0 20px;
    border-radius: 10px;  
    list-style: none;
    position: relative;
    display: inline-table;
}
    cat ul:after {
        content: ""; clear: both; display: block;
    }

    cat ul li {
        float: left;
    }
        cat ul li:hover {
            background: #4b545f;
            background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
            background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);
            background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%);
        }
            cat ul li:hover a {
                color: #fff;
            }

        cat ul li a {
            display: block; padding: 25px 40px;
            color: #757575; text-decoration: none;
        }


    cat ul ul {
        background: #5f6975; border-radius: 0px; padding: 0;
        position: absolute; top: 100%;
    }
        cat ul li {
            float: none; 
            border-top: 1px solid #6b727c;
            border-bottom: 1px solid #575f6a; position: relative;
        }
            cat ul ul li a {
                padding: 15px 40px;
                color: #fff;
            }   
                cat ul ul li a:hover {
                    background: #4b545f;
                }

    cat ul ul ul {
        position: absolute; left: 100%; top:0;
    }

this is the link
try to go Sekolah > Iklim > Piagam
the submenu will disappear because the mouse hover on the background wording which is the 'Recent Articles'.
Please help to make the submenu stay even hover on background wording.

Dani AI

Generated

The behavior you described (submenu vanishing when the pointer passes over the header/“Recent Articles” area) is exactly the classic stacking/overlay problem spotted and fixed by raising the menu’s stacking order. The submenu is working, but another element sits above it and steals hover/pointer events — that makes the browser think the mouse left the submenu and so it closes.

Why that happens: z-index only takes effect inside a stacking context. Elements that create stacking contexts (position + z-index, or properties like transform, opacity < 1, filter, will-change, etc.) confine how children are layered. If the header/hero text has its own stacking context or a higher z-index, simply styling the submenu won’t help unless you place the entire menu container above that stacking context.

Practical troubleshooting and fixes:

  • Inspect the overlapping element in DevTools: check computed styles for position, z-index, transform, opacity, filter, isolation, or will-change. Temporarily toggle pointer-events: none on that element to confirm it’s the culprit.
  • Preferred fix: give the top-level menu container a positioned stacking context above the header (position: relative/absolute and a higher z-index). That keeps flyouts above page content without touching the header’s code.
  • If the header must visually sit above the page but shouldn’t block the menu, lower its z-index or, only if safe, use pointer-events: none on purely decorative layers (this disables clicks).
  • Watch out: transforms or CSS filters on ancestors can block z-index changes. If an ancestor creates a stacking context, move the z-index change up to a higher ancestor.

Minimal example (use your own selectors):

/* give the navigation a stacking context above other page elements */
.main-nav { position: relative; z-index: 100; }

/* flyouts above the main nav */
.main-nav ul ul { position: absolute; z-index: 200; }

’s quick z-index suggestion is correct and simplest in many cases; if that ever fails, follow the DevTools checks above to find the stacking context that’s still above your menu.

Recommended Answers

All 3 Replies

When I access the site I see the words "Professional Online.." over the menu and Recent Articles behind it. Not sure what you mean by the mouse hover.

Give the sub menu a high z-index - the Professional Education bit is sitting over the flyout menu.

I set for cat ul z-index:50 and it worked, you probably don't need as high a value as that, but I didn't bother looking for a smaller answer.

thank u drjohn. it works..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.