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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <html id="root" style="position: relative">
<head>
	<link href='https://fonts.googleapis.com/css?family=Lora' rel='stylesheet'>
  <link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet'>
   <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Ubuntu" />
</head>
<html>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Lora:ital@1&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Lato:wght@300&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Lato:wght@300&family=Ubuntu:wght@300&display=swap");

#root {
  position: relative;
}

#quote-box {
  margin: 150px 0 0 -225px;
  padding: 20px;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 450px;
  border-radius: 8px;
  z-index: 1;
  background: #fff;
}

#text {
  font-family: "Lora";
  font-size: 25px;
}

#author {
  font-family: "Lato";
  font-size: 20px;
  text-align: right;
}

#new-quote {
  font-family: "Ubuntu";
  color: #fff;
}

.links {
  padding: 5px;
}

              
            
!

JS

              
                const mainColor= ["#BDB76B", "#228B22", "#00FA9A", "#808000", "#6B8E23", "#008B8B", "#00BFFF", "#000080", "#7B68EE", "#FF00FF", "#4B0082", "#C71585", "#808080", "#2F4F4F", "#DAA520", "#800000", "#D2691E", "#778899", "#40E0D0", "#F0E68C"];
      
const QuoteBox = function(props){
  const quoteBoxStyles =  {
  margin: "150px 0 0 -225px",
  padding: "20px",
  position: "absolute",
  top: "50%",
  left: "50%",
  width: "400px",
  borderRadius: "8px",
  zIndex: "1",
  background: "#fff",
  color: mainColor[props.randomIndex]
},
textStyles = {
  fontFamily: "Lora",
  fontSize: "25px",
  color: mainColor[props.randomIndex]
},
authorStyles = {
  fontFamily: "Lato",
  fontSize: "20px",
  textAlign: "right"
},
newQuoteStyles = {
  fontFamily: "Ubuntu",
  color: "#fff",
  background: mainColor[props.randomIndex],
  width: "100%",
  borderRadius: "5px",
  padding: "10px"
},
linksStyles = {
  padding: "5px",
};
  
    return (
      <div id="quote-box" className="container-fluid" style={quoteBoxStyles}>
        <p id="text" style={textStyles}> {props.quotes[props.randomIndex].quote} </p>
        <p id="author" style={authorStyles}>- {props.quotes[props.randomIndex].author}</p>
        <button id="new-quote" onClick={() => {props.onClick()}} className="btn btn-block" style={newQuoteStyles}>New Quote</button><br/>
        <a id="tweet-quote" href={'https://twitter.com/intent/tweet?text="'+props.quotes[props.randomIndex].quote+'" -'+props.quotes[props.randomIndex].author} className="links" target="_blank">
			Twitter
		</a>
		<a id="facebook" href="https://www.facebook.com/" className="links" target="_blank" style={linksStyles}>
			Facebook
		</a>
      <i className="fas fa-camera"></i>
      </div>
    );
  }

class Main extends React.Component{
	constructor(props){
		super(props);
		this.state = {
			quotes: [
        {quote: 'You either die a hero or live long enough to see yourself become  a villain.',
        author: 'Harvey Dent'},
        {quote: 'The greatest glory in living lies not in never falling, but in rising every time we fall.', 
        author: 'Nelson Mandela'},
        {quote: 'The way to get started is to quit talking and begin doing.', 
        author: 'Walt Disney'},
        {quote: "Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma – which is living with the results of other people's thinking.", 
        author: 'Steve Jobs'},
        {quote: 'If life were predictable it would cease to be life, and be without flavor.', 
        author: 'Eleanor Roosevelt'},
        {quote: "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.", 
        author: 'Oprah Winfrey'},
        {quote: "If you set your goals ridiculously high and it's a failure, you will fail above everyone else's success.", 
        author: 'James Cameron'},
        {quote: "Life is what happens when you're busy making other plans", 
        author: 'John Lennon'},
        {quote: "Spread love everywhere you go. Let no one ever come to you without leaving happier.", 
        author: 'Mother Teresa'},
        {quote: "When you reach the end of your rope, tie a knot in it and hang on.", 
        author: 'Franklin D. Roosevelt'},
        {quote: "Always remember that you are absolutely unique. Just like everyone else.", 
        author: 'Margaret Mead'},
        {quote: "The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart.", 
        author: 'Helen Keller'},
        {quote: "Whoever is happy will make others happy too.", 
        author: 'Anne Frank'},
        {quote: "Tell me and I forget. Teach me and I remember. Involve me and I learn.", 
        author: 'Benjamin Franklin'},
        {quote: "In the end, it's not the years in your life that count. It's the life in your years.", 
        author: 'Abraham Lincoln'},
        {quote: "Many of life's failures are people who did not realize how close they were to success when they gave up.", 
        author: 'Thomas A. Edison'},
        {quote: "Life is never fair, and perhaps it is a good thing for most of us that it is not.", 
        author: 'Oscar Wilde'},
        {quote: "Only a life lived for others is a life worthwhile.", 
        author: 'Albert Einstein'},
        {quote: "The purpose of our lives is to be happy.", 
        author: 'Dalai Lama'},
        {quote: "Love the life you live. Live the life you love.", 
        author: 'Bob Marley'}
      ],
			randomIndex: Math.floor(Math.random()*20)
		}	
	}
	
	
  generateRandomIndex(){
    this.setState({randomIndex: Math.floor(Math.random()*20)});
  }
	
	
	render(){
		return(
			<div>
        
        <QuoteBox quotes={this.state.quotes} randomIndex={this.state.randomIndex} onClick={() => {this.generateRandomIndex()}}/>
			</div>
		)
	}
}
ReactDOM.render(<Main/>, document.getElementById('root'));
              
            
!
999px

Console