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

              
                <!DOCTYPE html>
<html lang="en">
<head>
  <title>Random Quote Machine</title>
  <meta charset="utf-8">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"/>
  <link href="css/style.css" rel="stylesheet">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
</head>

<body>
  <div class="container">
      <div id="quote-box">
        <div id="quote-text">
            <i class="fas fa-quote-left"></i>
            <span id="text"></span>
            <i class="fas fa-quote-right"></i>
        </div>
        <div class="author">- <span id="author"></span></div>
        <div id="buttons" class="row" class="text-center">
          <div class="col-sm-6">
            <a id="tweet-quote" class="button btn-lg" title="Tweet this Quote!" href="#" target="_top" >Tweet Quote
            </a>
          </div>
            <div class="col-sm-6">
                <button id="new-quote" class="button btn-lg"  title="New Quote">New Quote</button>
            </div>
        </div>
      </div>
        <div class="footer">
             <h3>by Isaias Dominguez</h3>
        </div>
  </div>

  <script src="script.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</body>
</html>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Raleway:400,500');
* {
    margin: 0;
    padding: 0;
    list-style: none;
    vertical-align: baseline;
}
div {
    position: relative;
    z-index: 2;
}
body{
    font-family: 'Raleway', sans-serif;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
    height: 100vh;
}
.footer{
    width: 450px;
    text-align: center;
    display: block;
    margin: 30px auto 0px auto;
    font-size: 0.8em;
    color:white;
}
.footer h3{
    font-style: italic;
    font-weight: 500;
    text-decoration: none;
    color:white;
}
#quote-box {
    border-radius: 3px;
    position: relative;
    width: 550px;
    margin-left: auto;
    margin-right: auto;
    padding: 40px 50px;
    display:block;
    background-color: white;
    }
  
.quote-text {
    font-size: 40px;
    font-weight: 500;
    text-align: center;
    margin: auto;
    padding: 20px 20px;
    width: 450px;
    height: auto;
    clear: both;
    box-sizing: border-box;
}
.quote-text i{
    font-size: 1em;
    margin-right: 0.4em;
}
.author{
    width: 450px;
    height: auto;
    clear: both;
    padding-top: 20px;
    padding-right: 20px;
    font-size: 2rem;
    text-align: right;
}
#buttons{
    width: 450px;
    margin: auto;
    display: block;
}
.button{
    height: 38px;
    border: none;
    border-radius: 3px;
    color: #fff;
    background-color: #333;
    outline: none;
    font-size: 0.85em;
    padding: 8px 18px 6px 18px;
    margin-top: 30px;
    opacity: 1;
    cursor: pointer;
}
.button:hover{
    opacity: 0.9;
}
#tweet-quote, #new-quote{
    float: left;
    color: white;
    padding: 0px;
    padding-top: 8px;
    text-align: center;
    font-size: 1.2em;
    margin-right: 5px;
}
#new-quote{
    float: right;
}
              
            
!

JS

              
                window.onload= go;
var colors = [
    '#16a085',
    '#27ae60',
    '#2c3e50',
    '#f39c12',
    '#e74c3c',
    '#9b59b6',
    '#FB6964',
    '#342224',
    '#472E32',
    '#BDBB99',
    '#77B1A9',
    '#73A857'
  ];
function go(){
    $("#new-quote").click(function(){
        getRandQuote();
        getColor();
    });
    $('#tweet-quote').click(function(){
       
    });

    getRandQuote();
    getColor();
    
}
function getColor(){
    var color = Math.floor(Math.random() * colors.length);
    $('html body').css(
        {
          backgroundColor: colors[color],
          color: colors[color]
        }
      );
    $('.button').css(
        {
          backgroundColor: colors[color]
        }
      );
    $('.footer').css(
        {
            backgroundColor: colors[color]
        }
    );

}
function getRandQuote(){
    var quotes = [{
        id: 1,
		text: "I have just three things to teach: simplicity, patience, compassion. These three are your greatest treasures.",
		source: "Lao Tzu"
	},
	{
		id: 2,
		text: "Do today what others won't and achieve tomorrow what others can't.",
		source: "Jerry Rice"
	},
	{
		id: 3,
		text: "In character, in manner, in style, in all things, the supreme excellence is simplicity.",
		source: "Henry Wadsworth Longfellow"
	},
	{
		id: 4,
		text: "If we don't discipline ourselves, the world will do it for us.",
		source: "William Feather"
	},
	{
		id: 5,
		text: "Rule your mind or it will rule you.",
		source: "Horace"
	},
	{
		id: 6,
		text: "All that we are is the result of what we have thought.",
		source: "Buddha"
	},
	{
		id: 7,
		text: "Doing just a little bit during the time we have available puts you that much further ahead than if you took no action at all.",
		source: "Pulsifer, Take Action; Don't Procrastinate"
	},
	{
		id: 8,
		text: "Never leave that till tomorrow which you can do today.",
		source: "Benjamin Franklin"
	},
	{
		id: 9,
		text: "Procrastination is like a credit card: it's a lot of fun until you get the bill.",
		source: "Christopher Parker"
	},
	{
		id: 10,
		text: "Someday is not a day of the week.",
		source: "Author Unknown"
	},
	{
		id: 11,
		text: "Tomorrow is often the busiest day of the week.",
		source: "Spanish Proverb"
	},
	{
		id: 12,
		text: "I can accept failure, everyone fails at something. But I can't accept not trying.",
		source: "Michael Jordan"
	},
	{
		id: 13,
		text: "There’s a myth that time is money. In fact, time is more precious than money. It’s a nonrenewable resource. Once you’ve spent it, and if you’ve spent it badly, it’s gone forever.",
		source: "Neil A. Fiore"
	},
	{
		id: 14,
		text: "Nothing can stop the man with the right mental attitude from achieving his goal; nothing on earth can help the man with the wrong mental attitude.",
		source: "Thomas Jefferson"
	},
	{
		id: 15,
		text: "There is only one success--to be able to spend your life in your own way.",
		source: "Christopher Morley"
	},
	{
		id: 16,
		text: "Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.",
		source: "Evan Esar"
	},
	{
		id: 17,
		text: "We are still masters of our fate. We are still captains of our souls.",
		source: "Winston Churchill"
	},
	{
		id: 18,
		text: "Our truest life is when we are in dreams awake.",
		source: "Henry David Thoreau"
	},
	{
		id: 19,
		text: "The best way to make your dreams come true is to wake up.",
		source: "Paul Valery"
	},
	{
		id: 20,
		text: "Life without endeavor is like entering a jewel mine and coming out with empty hands.",
		source: "Japanese Proverb"
	},
	{
		id: 21,
		text: "Happiness does not consist in pastimes and amusements but in virtuous activities.",
		source: "Aristotle"
	},
	{
		id: 22,
		text: "By constant self-discipline and self-control, you can develop greatness of character.",
		source: "Grenville Kleiser"
	},
	{
		id: 23,
		text: "The difference between a successful person and others is not a lack of strength, not a lack of knowledge, but rather a lack in will.",
		source: "Vince Lombardi Jr."
	},
	{
		id: 24,
		text: "At the end of the day, let there be no excuses, no explanations, no regrets.",
		source: "Steve Maraboli"
	},
	{
		id: 25,
		text: "Inaction will cause a man to sink into the slough of despond and vanish without a trace.",
		source: "Farley Mowat"
	},
	{
		id: 26,
		text: "True freedom is impossible without a mind made free by discipline.",
		source: "Mortimer J. Adler"
	},
	{
		id: 27,
		text: "The most powerful control we can ever attain, is to be in control of ourselves.",
		source: "Chris Page"
	},
	{
		id: 28,
		text: "Idleness is only the refuge of weak minds, and the holiday of fools.",
		source: "Philip Dormer Stanhope"
	},
	{
		id: 29,
		text: "This is your life and it's ending one minute at a time.",
		source: "Tyler Durden, Fight Club"
	},
	{
		id: 30,
		text: "You create opportunities by performing, not complaining.",
		source: "Muriel Siebert"
	},
	{
		id: 31,
		text: "Great achievement is usually born of great sacrifice, and is never the result of selfishness.",
		source: "Napoleon Hill"
	},
	{
		id: 32,
		text: "Whether you think you can, or you think you can't, you're right.",
		source: "Henry Ford"
	},
	{
		id: 33,
		text: "Even if I knew that tomorrow the world would go to pieces, I would still plant my apple tree.",
		source: "Martin Luther"
	},
	{
		id: 34,
		text: "Great acts are made up of small deeds.",
		source: "Lao Tzu"
	},
	{
		id: 35,
		text: "The flame that burns Twice as bright burns half as long.",
		source: "Lao Tzu"
	},
	{
		id: 36,
		text: "Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away.",
		source: "Antoine de Saint-Exupery"
	},
	{
		id: 37,
		text: "If you can't do great things, do small things in a great way.",
		source: "Napoleon Hill"
	},
	{
		id: 38,
		text: "When I let go of what I am, I become what I might be.",
		source: "Lao Tzu"
	},
	{
		id: 39,
		text: "Do not go where the path may lead, go instead where there is no path and leave a trail.",
		source: "Ralph Waldo Emerson"
	},
	{
		id: 40,
		text: "Well done is better than well said.",
		source: "Benjamin Franklin"
	},
	{
		id: 41,
		text: "Whatever you think the world is withholding from you, you are withholding from the world.",
		source: "Ekhart Tolle"
	},
	{
		id: 42,
		text: "Muddy water is best cleared by leaving it alone.",
		source: "Alan Watts"
	},
	{
		id: 43,
		text: "Do, or do not. There is no try.",
		source: "Yoda"
	},
	{
		id: 44,
		text: "The superior man is modest in his speech, but exceeds in his actions.",
		source: "Confucius"
	},
	{
		id: 45,
		text: "Optimism is the faith that leads to achievement. Nothing can be done without hope and confidence.",
		source: "Helen Keller",
	},
	{
		id: 46,
		text: "We must believe that we are gifted for something, and that this thing, at whatever cost, must be attained.",
		source: "Marie Curie"
	},
	{
		id: 47,
		text: "If you look at what you have in life, you’ll always have more. If you look at what you don’t have in life, you’ll never have enough.",
		source: "Oprah Winfrey"
	},
	{
		id: 48,
		text: "You may encounter many defeats, but you must not be defeated. In fact, it may be necessary to encounter the defeats, so you can know who you are, what you can rise from, how you can still come out of it.",
		source: "Maya Angelou"
	},
	{
		id: 49,
		text: "We need to start work with the idea that we’re going to learn every day. I learn, even at my position, every single day.",
		source: "Chanda Kochhar"
	},
	{
		id: 50,
		text: "There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there.",
		source: "Indira Gandhi"
	},
	{
		id: 51,
		text: "You can’t be that kid standing at the top of the waterslide, overthinking it. You have to go down the chute.",
		source: "Tina Fey"
	},
	{
		id: 52,
		text: "Above all, be the heroine of your life, not the victim.",
		source: "Nora Ephron"
	},
	{
		id: 53,
		text: "Learn from the mistakes of others. You can’t live long enough to make them all yourself.",
		source: "Eleanor Roosevelt"
	},
	{
		id: 54,
		text: "What you do makes a difference, and you have to decide what kind of difference you want to make.",
		source: "Jane Goodall"
	},
	{
		id: 55,
		text: "One of the secrets to staying young is to always do things you don’t know how to do, to keep learning.",
		source: "Ruth Reichl"
	},
	{
		id: 56,
		text: "If you don’t risk anything, you risk even more.",
		source: "Erica Jong"
	},
	{
		id: 57,
		text: "When the whole world is silent, even one voice becomes powerful.",
		source: "Malala Yousafzai"
	},
	{
		id: 58,
		text: "The most common way people give up their power is by thinking they don’t have any.",
		source: "Alice Walker"
	},
	{
		id: 59,
		text: "My philosophy is that not only are you responsible for your life, but doing the best at this moment puts you in the best place for the next moment.",
		source: "Oprah Winfrey"
	},
	{
		id: 60,
		text: "Don’t be intimidated by what you don’t know. That can be your greatest strength and ensure that you do things differently from everyone else.",
		source: "Sara Blakely"
	},
	{
		id: 61,
		text: "If I had to live my life again, I’d make the same mistakes, only sooner.",
		source: "Tallulah Bankhead"
	},
	{
		id: 62,
		text: "Never limit yourself because of others’ limited imagination; never limit others because of your own limited imagination.",
		source: "Mae C. Jemison"
	},
	{
		id: 63,
		text: "If you obey all the rules, you miss all the fun.",
		source: "Katharine Hepburn"
	},
	{
		id: 64,
		text: "Life shrinks or expands in proportion to one’s courage.",
		source: "Anaïs Nin"
	},
	{
		id: 65,
		text: "Avoiding danger is no safer in the long run than outright exposure. The fearful are caught as often as the bold.",
		source: "Helen Keller"
	},
	{
		id: 66,
		text: "How wonderful it is that nobody need wait a single moment before beginning to improve the world.",
		source: "Anne Frank"
	},
	{
		id: 67,
		text: "So often people are working hard at the wrong thing. Working on the right thing is probably more important than working hard.",
		source: "Caterina Fake"
	},
	{
		id: 68,
		text: "There are still many causes worth sacrificing for, so much history yet to be made.",
		source: "Michelle Obama"
	},
	{
		id: 69,
		text: "Nothing is impossible; the word itself says ‘I’m possible’!",
		source: "Audrey Hepburn"
	},
	{
		id: 70,
		text: "You only live once, but if you do it right, once is enough.",
		source: "Mae West"
    },
    ];
    var randQuote = quotes[Math.floor(Math.random() * (quotes.length))];
    $("#text").html(randQuote.text);
    $("#author").html(randQuote.source);
    $("#tweet-quote").attr('href', stringToClickToTweetURL('"' + randQuote.text + '" - ' + randQuote.source));
}

function stringToClickToTweetURL(str){
    var stringToConvert = str.split(" ").join("%20").split("@").join("%40").split("!").join("%21");

  var resultString = "https://twitter.com/intent/tweet?text=" + stringToConvert;

  return resultString;
}

              
            
!
999px

Console