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

              
                <!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Alpine.js -->
<script src="//unpkg.com/alpinejs" defer></script>

<div class="w-full h-screen flex items-center justify-center">
  <div class="max-w-[650px]">
    <div
      x-data="{ activeSlide: 1, slideCount: 3 }"
      class="overflow-hidden relative"
    >
      <!-- Slider -->
      <!-- You can remove x-init if you dont want to autoplay -->
        <div
          class="whitespace-nowrap transition-transform duration-500 ease-in-out"
          :style="'transform: translateX(-' + (activeSlide - 1) * 100.5 + '%)'"
          x-init="setInterval(() => { activeSlide = activeSlide < slideCount ? activeSlide + 1 : 1 }, 5000)"
        >
          <!-- Item 1 -->
          <div class="inline-block w-full max-h-[360px]">
            <img
              src="https://c4.wallpaperflare.com/wallpaper/994/253/68/japan-mountains-mount-fuji-asian-architecture-wallpaper-preview.jpg"
              alt=""
            />
          </div>
          <!-- Item 2 -->
          <div class="inline-block w-full max-h-[360px]">
            <img
              src="https://wallpapers.com/images/featured/tree-0wdwtdt9xzcm91b1.jpg"
              alt=""
            />
          </div>
          <!-- Item 3 -->
          <div class="inline-block w-full max-h-[360px]">
            <img
              src="https://images.unsplash.com/photo-1451187580459-43490279c0fa?q=80&w=1000&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8d29ybGR8ZW58MHx8MHx8fDA%3D"
              alt=""
            />
          </div>
        </div>

      <!-- Prev/Next Arrows -->
      <div class="absolute inset-0 flex items-center justify-between px-2">
        <button
          @click="activeSlide = activeSlide > 1 ? activeSlide - 1 : slideCount"
          class="w-[30px] h-[30px] flex items-center bg-black/30 text-white p-2 rounded-full"
        >
          &#8592;
        </button>
        <button
          @click="activeSlide = activeSlide < slideCount ? activeSlide + 1 : 1"
          class="w-[30px] h-[30px] flex items-center bg-black/30 text-white p-2 rounded-full"
        >
          &#8594;
        </button>
      </div>

      <!-- Dots Navigation -->
      <div
        class="absolute bottom-0 left-0 right-0 flex justify-center space-x-2 p-4"
      >
        <template x-for="slideIndex in slideCount" :key="slideIndex">
          <button
            @click="activeSlide = slideIndex"
            class="h-2 w-2 rounded-full"
            :class="{'bg-orange-500': activeSlide === slideIndex, 'bg-white/50': activeSlide !== slideIndex}"
          ></button>
        </template>
      </div>
    </div>
  </div>
</div>

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console