Article View: comp.lang.javascript
Article #32Re: main menu
From: Thomas 'PointedEars' Lahn
Date: Wed, 18 Nov 2026 23:18
Date: Wed, 18 Nov 2026 23:18
63 lines
2688 bytes
2688 bytes
Dale wrote:
> How can I do the main menu on ...
>
> https://www.w3.org/
>
> ?
There are many ways. Most involve using a client-side framework for
which code may be generated server-side. Usually it is generated by a CMS.
But toggling a main menu like this can be done without scripting, using
just a checkbox and CSS; e.g.:
.nav {
display: relative;
}
.nav .checkbox {
position: absolute:
visibility: hidden;
}
.nav .checkbox + .checkbox-label {
/* appearance of the menu button when the main menu is hidden */
}
.nav .checkbox:checked + .checkbox-label {
/* appearance of the menu button when the main menu is shown */
}
.nav .checkbox + .checkbox-label + .menu {
display: none;
}
.nav .checkbox:checked + .checkbox-label + .menu {
display: block;
}
HTML:
<nav class='nav'>
<input type='checkbox' class='checkbox' id='cbMenu'>
<label for='cbMenu' class='checkbox-label'
title='Toggle menu'>foo</label>
<menu class='menu'>
<li>...</li>
</menu>
</nav>
> I have been on and doing website since mid-90's
>
> new to javascripts
There is no "javascript(s)".
Given your point in the learning curve, I recommend to attempt to do it
without scripting first. At some point you will need to learn and use
CSS anyway.
--
PointedEars
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
Technical Details
Message-ID:
<11dlbnk$l065$1@gwaiyur.mb-net.net>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!.POSTED!not-for-mailReferences:
<vnadneGOjuwqA3z3nZ2dnZfqnPidnZ2d@supernews.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn <PointedEars@web.de> Newsgroups: alt.comp.lang.javascript,comp.lang.javascript Subject: Re: main menu Followup-To: comp.lang.javascript Date: Thu, 19 Nov 2026 00:18:10 +0100 Organization: PointedEars Software (PES) Message-ID: <11dlbnk$l065$1@gwaiyur.mb-net.net> References: <vnadneGOjuwqA3z3nZ2dnZfqnPidnZ2d@supernews.com> Reply-To: Thomas 'PointedEars' Lahn <usenet@PointedEars.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 18 Nov 2026 23:18:12 -0000 (UTC) Injection-Info: gwaiyur.mb-net.net; logging-data="688325"; mail-complaints-to="abuse@open-news-network.org" User-Agent: Betterbird (Windows) Cancel-Lock: sha1:9jNeHfXJzcKs4kKAHWZrkOLHC0E= sha256:frAJz6J/naLQwcaJRAZZjhkx29LpOJd8b+e/uAYs20Q= sha1:1SESpSPeSByLKMIHUzdkc6iN6FY= sha256:x268naBJeBgvxAZLuh5ETt4oIZk0WFGyN8axN06TT6c= Content-Language: en-US, de-CH, de-DE In-Reply-To: <vnadneGOjuwqA3z3nZ2dnZfqnPidnZ2d@supernews.com>