Pen Settings

HTML

CSS

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.

+ 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

              
                <div class="feathers">
  <div class="container-fluid">
    <div class="card">
      <div class="content">
        <p id="quote"></p>
        <span style="font-size: 40%"> </span>
        <em><p id="author"></p></em>
      </div>
      <i class="fa fa-twitter" aria-hidden="true"></i>
      <div class="next">NEXT</div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                %basics {
  margin: 0;
  padding: 0;
}

body {
  @extend %basics;
  background: linear-gradient(90deg, #ff4d4d, #006699, #009999, #ffa64d);
}

.feathers {
  @extend %basics;
  height: 100vh;
  background-image: radial-gradient(circle at 45% 0%, transparent 17px, rgba(255, 255, 255, .4) 20px, transparent 6px);
  background-size: 40px 30px;
}

.card {
  background: rgba(255, 255, 2555, .85);
  box-shadow: 10px 10px 10px rgba(0, 0, 0, .3);
  margin: 4% auto;
  height: auto;
  width: 60%;
  max-width: 1000px;
  min-width: 500px;
  min-height: 150px;
  padding: 2% 2% 3% 2%;
  position: relative;
}

p,
.next {
  font-family: "Quicksand", sans-serif;
}

#quote {
  font-size: 150%;
  margin: 1% 2%;
  top: 50%;
  position: relative;
  text-align: center;
}

#author {
  font-size: 120%;
  text-align: center;
  margin: 15px;
}

%button {
  background: black;
  bottom: 20px;
  color: white;
  position: absolute;
  margin-top: 20px;
  text-align: center;
}

.next {
  @extend %button;
  font-size: 115%;
  width: 13%;
  line-height: 0px;
  padding: 3% 0;
  float: right;
  right: 30px;
  &.active {
    background: white;
  }
}

.fa-twitter {
  @extend %button;
  border-radius: 100%;
  float: left;
  font-size: 125%;
  padding: 2%;
  left: 30px;
}

.fa-twitter:hover,
.next:hover {
  cursor: pointer;
  font-weight: bold;
  transform: scale(1.05);
}

@media only screen and (max-width: 600px) {
  .card {
    height: 50%;
    margin-top: 15%;
    max-width: 430px;
    min-width: 250px;
    padding: 4%;
    padding-bottom: 40px;
  }
  .quote {
    margin: 0.5% 0;
  }
  %button {
    bottom: 20px;
  }
  .next {
    font-size: 105%;
    height: 5%;
    width: 20%;
    padding: 5% 0;
    float: right;
    right: 20px;
  }
  .fa-twitter {
    left: 20px;
  }
}
              
            
!

JS

              
                // Load a quote from Forismatic
function parseQuote(content) {
  // Get height prior to auto resizing
  var card = $(".card"),
    oldHeight = card.height();

  // Update quote
  $('#quote').text(content.quoteText);

  // Update and check author
  if (content.quoteAuthor == "") {
    $('#author').text('- Unknown');
  } else {
    $("#author").text('-  ' + content.quoteAuthor);
  }

  // Card tricks - animate height changes
  animateHeight(card, oldHeight);

  // Unfade the contents 
  $('.content').fadeIn();

}

function animateHeight(card, oldHeight) {
  // Get the new height
  var newHeight = card.css('height', '30%').height();
  
  // Additions for button alignment
  // Amount added is dependent on the device
  if (window.innerWidth < 600){
    newHeight += 65;
  } else {
    newHeight += 40;
  }
  
  // Restore old height then animate to new height
  card.height(oldHeight).animate({
    height: newHeight
  });

}

// Trying out 2 methods to get  conent
// Update the HTML
var tag = document.createElement('script');
tag.src = "https://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=parseQuote";
$('#quote').html(tag);

// Update the contents
$('.next').click(function() {
  $('.content').fadeOut();
  $.ajax({
    url: 'https://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=parseQuote',
    dataType: 'jsonp',
    error: function(xhr, status, error) {
      $('.quote').text('ERROR 404');
      $('.author').text('Technical Difficulties');
    }
  });
});

// Tweet tweet 
$('.fa-twitter').click(function() {
  var url = 'https://codepen.io/'
  var text = $('#quote').text() + ' ' + $("#author").text();

  window.open('https://twitter.com/share?url=' + encodeURIComponent(url) + '&text=' + encodeURIComponent(text), '', '');

});
              
            
!
999px

Console