Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- Include CDN JavaScript -->
<script src="https://unpkg.com/tailwindcss-jit-cdn"></script>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.8.2/dist/alpine.min.js" defer></script>

<header>
    <a href="#main-content" role="button" aria-label="Skip to main content" class="flex flex-col justify-center skip-main" style="height:40px;">Skip to main content</a><!-- /.skip-main -->
    
<!-- >>> TEMPLATE BEGIN >>> _includes/main-nav -->
<nav class="bg-white border-b border-gray-200">
  <div class="w-full text-gray-700 max-w-screen container">
    <div x-data="{ open: false }" class="flex flex-col mx-auto ax-w-screen lg:flex-row">

      <div class="flex flex-row items-center justify-between px-4 py-2">
        <a href="/" class="text-lg font-semibold tracking-widest text-gray-900 uppercase    dark-mode:text-white focus:outline-none focus:shadow-outline">
          insert logo
          <span class="sr-only">Home</span>
        </a>

        <button class="mr-8 rounded-lg md:mr-12 lg:hidden focus:outline-none focus:shadow-outline" @click="open = !open">
                    <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512.001 512.001" x-show="open" style="display: none;"><path d="M284.286 256.002L506.143 34.144c7.811-7.811 7.811-20.475 0-28.285-7.811-7.81-20.475-7.811-28.285 0L256 227.717 34.143 5.859c-7.811-7.811-20.475-7.811-28.285 0-7.81 7.811-7.811 20.475 0 28.285l221.857 221.857L5.858 477.859c-7.811 7.811-7.811 20.475 0 28.285a19.938 19.938 0 0014.143 5.857 19.94 19.94 0 0014.143-5.857L256 284.287l221.857 221.857c3.905 3.905 9.024 5.857 14.143 5.857s10.237-1.952 14.143-5.857c7.811-7.811 7.811-20.475 0-28.285L284.286 256.002z"></path></svg>
          <span class="sr-only" x-show="open" style="display: none;">Close Menu</span><!-- /.sr-only -->

                    <svg class="h-6 w-6" width="40" height="40" viewBox="0 0 100 80" x-show="!open"><path d="M0 0h100v10H0zm0 30h100v10H0zm0 30h100v10H0z"></path></svg>
          <span class="sr-only" x-show="!open">Open Menu</span><!-- /.sr-only -->
        </button>
      </div>

      <nav class="flex-col flex-grow hidden h-screen pb-4 lg:pb-0 lg:flex lg:justify-start lg:flex-row lg:h-auto" aria-label="Main Navigation" :class="{'flex': open, 'hidden': !open}">
        <ul class="flex flex-col flex-wrap pl-0 m-0 lg:flex-row">

          
                      <li class="group relative
                            block lg:px-0 xl:px-0 mr-1 py-2" x-data="{isOpen:false }" @mouseleave="isOpen = false">

              <a href="#" class="py-2
                px-4 group-hover:bg-gray-400 group-hover:text-white" @click="isOpen = !isOpen" x-on:click.prevent="" :class="{'' : isOpen}">

                  About 
                
<svg xmlns="http://www.w3.org/2000/svg" fill="#000" width="16" height="16" class="hidden lg:inline-block relative top-0 right-0 transform rotate-90" viewBox="0 0 16 16">
                    <path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"></path>
                  </svg>                
                
              </a>

                            
                                
                                <ul class="bg-gray-600 p-2" aria-label="submenu" x-show="isOpen" @click.away="isOpen = false" style="display: none;">

                                      <li class="group relative border-b border-white border-opacity-[0.2]">
                     <a href="https://craft-starter.ddev.site/pages/about/" class="py-2 text-white bg-transparent hover:text-gray-100 lg:text-sm">About</a>
                   </li><!-- /.p-3 bg-green-200 -->
                   
                              <li class="group relative
                            border-b border-white border-opacity-[0.2]">

              <a href="https://craft-starter.ddev.site/pages/about-2/" class="py-2
                text-white bg-transparent hover:text-gray-100 lg:text-sm">

                  Sub Page
              </a>

                                          
            </li>
                      <li class="group relative
                            border-b border-white border-opacity-[0.2]" x-data="{isOpen:false }" @mouseleave="isOpen = false">

              <a href="#" class="py-2
                text-white bg-transparent hover:text-gray-100 lg:text-sm" @click="isOpen = !isOpen" x-on:click.prevent="" :class="{'' : isOpen}">

                  Sub Page 2
              </a>

                            
                                                  <svg xmlns="http://www.w3.org/2000/svg" fill="white" width="16" height="16" class="hidden lg:inline-block fill-white absolute top-[10px] right-0" viewBox="0 0 16 16">
                    <path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"></path>
                  </svg>
                
                                <ul class="bg-gray-600 p-2" aria-label="submenu" x-show="isOpen" @click.away="isOpen = false" style="display: none;">

                                      <li class="group relative border-b border-white border-opacity-[0.2]">
                     <a href="https://craft-starter.ddev.site/pages/about-2-2/" class="py-2 text-white bg-transparent hover:text-gray-100 lg:text-sm">Sub Page 2</a>
                   </li><!-- /.p-3 bg-green-200 -->
                   
                              <li class="group relative
                            border-b border-white border-opacity-[0.2]">

              <a href="https://craft-starter.ddev.site/pages/sub-sub-page/" class="py-2
                text-white bg-transparent hover:text-gray-100 lg:text-sm">

                  Sub Sub Page
              </a>

                                          
            </li>
                          </ul>
                            
            </li>
                      <li class="group relative
                            border-b border-white border-opacity-[0.2]">

              <a href="https://craft-starter.ddev.site/pages/about-2-2-2/" class="py-2
                text-white bg-transparent hover:text-gray-100 lg:text-sm">

                  Sub Page 3
              </a>

                                          
            </li>
                          </ul>
                            
            </li>
                      <li class="group relative
                            block lg:px-0 xl:px-0 mr-1 py-2">

              <a href="https://craft-starter.ddev.site/pages/services/" class="py-2
                px-4 group-hover:bg-gray-400 group-hover:text-white">

                  Services
              </a>

                                          
            </li>
                      <li class="group relative
                            block lg:px-0 xl:px-0 mr-1 py-2">

              <a href="https://craft-starter.ddev.site/pages/blog/" class="py-2
                px-4 group-hover:bg-gray-400 group-hover:text-white">

                  Blog
              </a>

                                          
            </li>
          
        </ul>
      </nav>



    </div>
  </div>
</nav>


<!-- 18.95ms <<< TEMPLATE END <<< _includes/main-nav -->
  </header>

<main id="main" class="my-8 px-4">

  <h1 class="text-2xl">Accessible Dropdown Navigation with Tailwind CSS and Alpine Js</h1>
  
  <div class="bg-yellow-200 p-8 my-8 max-w-lg">
    <p class="text-xl">
      The css tab on this codepen contains css from app.css that is compiled by laravel mix.</p>
      
<p class="text-xl"> See <a href="https://caffeinecreations.ca/blog/accessible-dropdown-navigation-with-tailwind-css-and-alpine-js/" class="underline hover:no-underline text-blue-500">blog post</a> for that css: 
      
    </p>
  </div>
  
</main>
              
            
!

CSS

              
                a.skip-main {
	position: absolute;
	top: 40px;
	height: 1px;
	width: 1px;
	overflow: hidden;
    left: -999px;
    z-index: -999;
    background: #2d2828;
}
a.skip-main:focus, a.skip-main:active {
	left: 5px;
	top: 50px;
	z-index: 999;
	margin-top: 10px;
	margin-bottom: 10px;
	margin-left: 5px;
	margin-right: 5px;
	min-width: 200px;
	border-width: 1px;
	--tw-border-opacity: 1;
	border-color: rgba(0, 0, 0, var(--tw-border-opacity));
	--tw-bg-opacity: 1;
	background-color: rgba(45, 40, 40, var(--tw-bg-opacity));
	padding: 10px;
	text-align: center;
	font-size: 1rem;
	line-height: 1.5rem;
	--tw-text-opacity: 1;
	color: rgba(255, 255, 255, var(--tw-text-opacity));
	text-decoration: none;
}
/* Nav */
nav li {
    -webkit-transition-duration: 0.5s;
            transition-duration: 0.5s;
  }
nav  li:hover, nav li:focus-within {
	cursor: pointer;
}
nav ul li ul {
	width: 100%;
	--tw-bg-opacity: 1;
	background-color: rgba(255, 255, 255, var(--tw-bg-opacity));
	--tw-bg-opacity: 1;
	background-color: rgba(156, 163, 175, var(--tw-bg-opacity));
	padding-left: 0px;
	padding-right: 0px;
	padding-top: 0.25rem;
	padding-bottom: 0.25rem;
	padding-left: 2rem;
}
@media (min-width: 1024px) {

	nav ul li ul {
		position: absolute;
	}

	nav ul li ul {
		left: 0px;
	}

	nav ul li ul {
		width: 180px;
	}

	nav ul li ul {
		min-width: 180px;
	}

	nav ul li ul {
		max-width: 180px;
	}

	nav ul li ul {
		padding-left: 0px;
	}

	nav ul li ul {
		--tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
		-webkit-box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
		        box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
	}
}
nav ul li ul {
    z-index:9999;
    -webkit-transition: all 0.5s ease;
    transition: all 0.5s ease;
    right: -20px;
  }
nav ul li a {
	display: block;
	background-color: transparent;
}
.group:hover nav ul li a {
	--tw-bg-opacity: 1;
	background-color: rgba(156, 163, 175, var(--tw-bg-opacity));
	--tw-text-opacity: 1;
	color: rgba(255, 255, 255, var(--tw-text-opacity));
}
nav ul li:hover > a {
	--tw-text-opacity: 1;
	color: rgba(17, 24, 39, var(--tw-text-opacity));
}
nav ul li ul ul {
	top: 0px;
    right: -180px;
    left:auto;
}
/* nav ul li ul li {
    width: 100%;
  } */
nav ul li img {
	position: absolute;
	right: 10px;
    top: calc(50% - 4px);
}
/* end nav */
              
            
!

JS

              
                
              
            
!
999px

Console