cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              
<header>
  <h1>Giphy Search</h1>
  
  <form action="" method="post">
    <label for="" style="display: none;">Search</label>
    <input class="search" type="text" name"search" placeholder="Search" required>
    <input class="btn" type="submit" value="OK">
    <input class="btn clear" value="Clear" readonly>
  </form>
</header>

<section>
  <div class="giphy">
    <a href="https://giphy.com/" target="_blank">
      <img src="https://res.cloudinary.com/beumsk/image/upload/v1520544016/giphy-logo-6611-s-_vme7aa.png" alt="giphy">
    </a>
  </div>
</section>

<footer>
  <p>Created by <a href="https://remybeumier.be" target="_blank">Rémy Beumier</a> with <a href="https://developers.giphy.com/docs/" target="_blank">Giphy API</a></p>
</footer>

            
          
!
            
              
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: Arial;
  text-align: center;
  min-height: 100vh;
  min-width: 370px;
  background-image: linear-gradient(135deg,#00ccff,#9933ff 31%,#e646b6 52%,#fff9aa 77%,#00ff99,#00ccff);
  background-size: 200%;
}

header h1 {
  padding: 20px 10px;
  letter-spacing: 0.2em;
  color: white;
}

form * {
  background: rgba(256,256,256, 0.3);
  color: white;
}

form .search, form .btn {
  padding: 10px;
  border-radius: 2px;
  font-size: 16px;
  border: 1px solid white;
}

::placeholder {
  color: #f5f5f5;
}

form .search {
  width: 40%;
  min-width: 200px;
  max-width: 600px; 
}
form .search:focus {
  outline: 0;
  color: #333;
  background: white;
  box-shadow: 0 0 1px 1px rgba(0,0,0,0.3);
}

form .btn {
  cursor: pointer;
  width: 60px;
}
form .btn:hover {
  color: #333;
  background: white;
}
form .clear:hover {
  background: ;
}

.giphy {
  padding: 20px 0 15px 0;
}

.giphy img {
  width: 200px;
  max-width: 800px;
  margin: auto;
  display: block;
}

.giphy img.gif {
  width: 50%;
  max-width: 600px;
  box-shadow: 0 0 1px 1px rgba(256,256,256,0.3);
}

footer {
  padding: 5px;
  font-size: 14px;
  color: white;
}

footer a {
  color: #333;
  text-decoration: none;
}
footer a:hover {
  color: white;
  text-decoration: underline;
}

            
          
!
            
              
// check other info returned by the API ???

var $form = $("form"),
    $search = $(".search"),
    $clear = $(".clear"),
    $giphy = $(".giphy img"),
    $giphyLink = $(".giphy a");

// launch function on form submit
$form.on("submit", function(e) {
  e.preventDefault();
  goGiphy();
});

// clear input on click
$clear.on("click", function() {
  $search.val("");
})

function goGiphy() {
  var input = $search.val();
  // Ajax call to giphy API  
  $.getJSON("https://api.giphy.com/v1/gifs/translate?api_key=bb2006d9d3454578be1a99cfad65913d&s=" + input, function(json) {
    data = JSON.parse(JSON.stringify(json));
    imgSrc = data.data.images.original.url;
    $giphy.fadeOut(1000);
    setTimeout( function() {
      $giphy.attr("src", imgSrc);
      $giphyLink.attr("href", imgSrc);
      setTimeout( function() {
        $giphy.addClass("gif");
        $giphy.fadeIn(1000);
      }, 800);
    }, 800);
  })
}

            
          
!
999px
Loading ..................

Console