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

Save Automatically?

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

              
                <!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>CodePen - alpine js-Photo Gallery</title>
  

</head>
<body>
<!-- partial:index.partial.html -->
<!DOCTYPE html>
<html dir="rtl" lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
  <script src="https://cdn.tailwindcss.com"></script>

  <title>Document</title>
</head>

<body x-data="images()" x-init="fetch('https://pixabay.com/api/?key=15819227-ef2d84d1681b9442aaa9755b8&q=yellow+flowers&image_type=photo')
.then(response => response.json())
.then(response => { images = response.hits })">
  <header class="absolute top-0 left-0 right-0 h-16 w-full">
    <nav class="container mx-auto flex items-center justify-between px-12 py-4 lg:px-36">
      <a class="w-24 lg:w-full" href="">
        <img src="https://i.postimg.cc/fTgpm23K/sitenema3-341x83-2-e1617898910767.png" alt="" />
      </a>

      <!-- hamberger -->
      <button class="lg:hidden">
        <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
          <path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16" />
        </svg>
      </button>
    </nav>
  </header>
  <div>
    <!-- hero start -->
    <section class="bg-[url('https://i.postimg.cc/zvXL1Kt5/2.jpg')] bg-cover bg-center pt-40 pb-28">
      <div class="container mx-auto px-16 lg:px-36">
        <div class="flex flex-col items-center justify-center space-y-3">
          <h1 class="text-2xl font-semibold text-white/80">جستجوی عکس</h1>
          <h2 class="text-xl font-normal text-white/70">می توانید عکس های با کیفیت را اینجا پیدا کنید</h2>
          <!-- search box -->
          <div x-model="q" dir="rtl" class="flex w-full items-stretch justify-center rounded lg:flex-wrap">
            <input class="flex-1 border-2 py-2 px-2 outline-none focus:border-sky-600" type="text" placeholder="جستجوی تصاویر" />
            <select x-model="image_type" class="ouline-none flex-1 border border-white py-2 text-gray-600 focus:border-sky-600" name="" id="" aria-placeholder="">
              <option selected>نوع تصویر را انتخاب کنید</option>
              <option value="all">همه</option>
              <option value="photo">عکس</option>
              <option value="illustration">تصاویر</option>
              <option value="vector">وکتور</option>
            </select>
            <div class="flex items-center rounded-l bg-sky-600 px-4 text-center text-white">
              <button @click="getImages()" class="inline-block align-text-top">جستجو</button>
            </div>
          </div>
        </div>
      </div>
    </section>
    <!-- hero end -->
    <!-- content start -->
    <section class=" grid grid-cols-5 gap-4 mt-4">
      <template x-for="image in images" :key="image.id">
        <div class=" border rounded shadow">
          <img class="h-auto  " :src="image.webformatURL" alt="image.tags[0]" />
        </div>
      </template>
    </section>
    <!-- content end -->
  </div>
  <script>
    function images() {
      return {
        images: [],
        q: "",
        image_type: "",
        getImages: async function() {
          console.log("params", this.q, this.image_type);
          const response = await fetch(
            `https://pixabay.com/api/?key=15819227-ef2d84d1681b9442aaa9755b8&q=${
                this.q
              }&image_type=${this.image_type}`
          );
          const data = await response.json();
          this.images = data.hits;
        }
      };
    }
  </script>
</body>

</html>
<!-- partial -->
  
</body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console