tailwindcss实现左侧弹出多级导航菜单效果代码

代码语言:html

所属分类:菜单导航

代码描述:tailwindcss实现左侧弹出多级导航菜单效果代码,点击菜单后右侧会显示不同内容。

代码标签: tailwind css 左侧 弹出 多级 导航 菜单

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">


    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/all.6.4.0.css">

    <style>
        @import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700");
        
        html, body {
        	font-family: Montserrat, sans-serif;
        }
    </style>

    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tailwindcss_3.3.3.js"></script>

</head>

<body>
    <div class="w-screen h-screen flex flex-col overflow-hidden">
        <header class="bg-slate-900 p-2 border-b border-slate-950 grow-0 shrink shadow-lg z-10"><a class="hover:bg-slate-950 text-white text-center w-10 p-2 inline-block rounded-lg transition-colors" href="#offcanvas"><i class="fa-solid fa-bars"></i></a></header>
        <div class="h-full flex flex-nowrap overflow-hidden relative [&amp;:target&gt;*]:left-0" id="offcanvas">
            <nav class="bg-slate-900 w-full h-full shrink-0 overflow-auto absolute -left-full transition-all sm:w-1/2 lg:w-1/4">
                <ul>
                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#home"><span><i class="fa-solid fa-house mr-2"></i>Home</span></a></li>
                    <li>
                        <label class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer [&amp;:has([type='checkbox']:checked)+ul]:max-h-[200vh] duration-1000 [&amp;:has([type='checkbox']:checked)&gt;span&gt;.caret&gt;i]:rotate-180 ">
            <input class="hidden" type="checkbox"/><span class="flex justify-between"><span><i class="fa-solid fa-box mr-2"></i>Products</span><span class="caret"><i class="transition-transform fa-solid fa-angle-down"></i></span></span>
          </label>
                        <ul class="max-h-0 overflow-hidden transition-all duration-100">
                            <li>
                                <label class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer [&amp;:has([type='checkbox']:checked)+ul]:max-h-[200vh] duration-1000 [&amp;:has([type='checkbox']:checked)&gt;span&gt;.caret&gt;i]:rotate-180 ">
                <input class="hidden" type="checkbox"/><span class="flex justify-between pl-4"><span><i class="fa-solid fa-dog mr-2"></i>Dog Supplies</span><span class="caret"><i class="transition-transform fa-solid fa-angle-down"></i></span></span>
              </label>
                                <ul class="max-h-0 overflow-hidden transition-all duration-100">
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#dog-food-treats"><span class="pl-8"><i class="fa-solid fa-bowl-food mr-2"></i>Food &amp; Treats</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#dog-toys"><span class="pl-8"><i class="fa-solid fa-paw mr-2"></i>Toys</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#dog-beds-furniture"><span class="pl-8"><i class="fa-solid fa-couch mr-2"></i>Beds &amp; Furniture</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#dog-outdoor-supplies"><span class="pl-8"><i class="fa-solid fa-campground mr-2"></i>Outdoor Supplies</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#dog-clothing"><span class="pl-8"><i class="fa-solid fa-shirt mr-2"></i>Clothing</span></a></li>
                                </ul>
                            </li>
                            <li>
                                <label class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer [&amp;:has([type='checkbox']:checked)+ul]:max-h-[200vh] duration-1000 [&amp;:has([type='checkbox']:checked)&gt;span&gt;.caret&gt;i]:rotate-180 ">
                <input class="hidden" type="checkbox"/><span class="flex justify-between pl-4"><span><i class="fa-solid fa-cat mr-2"></i>Cat Supplies</span><span class="caret"><i class="transition-transform fa-solid fa-angle-down"></i></span></span>
              </label>
                                <ul class="max-h-0 overflow-hidden transition-all duration-100">
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#cat-food-treats"><span class="pl-8"><i class="fa-solid fa-bowl-food mr-2"></i>Food &amp; Treats</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#cat-toys"><span class="pl-8"><i class="fa-solid fa-paw mr-2"></i>Toys</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#cat-beds-furniture"><span class="pl-8"><i class="fa-solid fa-couch mr-2"></i>Beds &amp; Furniture</span></a></li>
                                </ul>
                            </li>
                            <li>
                                <label class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer [&amp;:has([type='checkbox']:checked)+ul]:max-h-[200vh] duration-1000 [&amp;:has([type='checkbox']:checked)&gt;span&gt;.caret&gt;i]:rotate-180 ">
                <input class="hidden" type="checkbox"/><span class="flex justify-between pl-4"><span><i class="fa-solid fa-dove mr-2"></i>Bird Supplies</span><span class="caret"><i class="transition-transform fa-solid fa-angle-down"></i></span></span>
              </label>
                                <ul class="max-h-0 overflow-hidden transition-all duration-100">
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#bird-food-treats"><span class="pl-8"><i class="fa-solid fa-bowl-food mr-2"></i>Food &amp; Treats</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#bird-toys"><span class="pl-8"><i class="fa-solid fa-paw mr-2"></i>Toys</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#bird-furniture"><span class="pl-8"><i class="fa-solid fa-couch mr-2"></i>Furniture</span></a></li>
                                </ul>
                            </li>
                            <li>
                                <label class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer [&amp;:has([type='checkbox']:checked)+ul]:max-h-[200vh] duration-1000 [&amp;:has([type='checkbox']:checked)&gt;span&gt;.caret&gt;i]:rotate-180 ">
                <input class="hidden" type="checkbox"/><span class="flex justify-between pl-4"><span><i class="fa-solid fa-fish mr-2"></i>Fish Supplies</span><span class="caret"><i class="transition-transform fa-solid fa-angle-down"></i></span></span>
              </label>
                                <ul class="max-h-0 overflow-hidden transition-all duration-100">
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#fish-food"><span class="pl-8"><i class="fa-solid fa-bowl-food mr-2"></i>Food</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#fish-aquariums"><span class="pl-8"><i class="fa-solid fa-water mr-2"></i>Aquariums</span></a></li>
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#fish-docks-decorations"><span class="pl-8"><i class="fa-solid fa-droplet mr-2"></i>Rocks &amp; Decorations</span></a></li>
                                </ul>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <label class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer [&amp;:has([type='checkbox']:checked)+ul]:max-h-[200vh] duration-1000 [&amp;:has([type='checkbox']:checked)&gt;span&gt;.caret&gt;i]:rotate-180 ">
            <input class="hidden" type="checkbox"/><span class="flex justify-between"><span><i class="fa-solid fa-screwdriver-wrench mr-2"></i>Services</span><span class="caret"><i class="transition-transform fa-solid fa-angle-down"></i></span></span>
          </label>
                        <ul class="max-h-0 overflow-hidden transition-all duration-100">
                            <li>
                                <label class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer [&amp;:has([type='checkbox']:checked)+ul]:max-h-[200vh] duration-1000 [&amp;:has([type='checkbox']:checked)&gt;span&gt;.caret&gt;i]:rotate-180 ">
                <input class="hidden" type="checkbox"/><span class="flex justify-between pl-4"><span><i class="fa-solid fa-scissors mr-2"></i>Grooming</span><span class="caret"><i class="transition-transform fa-solid fa-angle-down"></i></span></span>
              </label>
                                <ul class="max-h-0 overflow-hidden transition-all duration-100">
                                    <li><a class="text-white hover:bg-slate-950 px-6 py-4 block transition-colors cursor-pointer" href="#coat-care"><span class="pl-8"><i class="fa-solid fa-spray-can-sparkles mr-2"></i>Coat Care</span></a></li>
                                    <li><a class=".........完整代码请登录后点击上方下载按钮下载查看

网友评论0