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 id='app'></div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=IBM+Plex+Sans:300i,400');

$clrs: #EF476F, #FFD166, #06D6A0, #118AB2, #073B4C;

*{
  padding:0;
  margin:0;
  color: black;
}

*,
:before,
:after {
    -webkit-box-sizing: border-box;
       -moz-box-sizing: border-box;
            box-sizing: border-box;
}

body, html, #app,{
  width: 100%;
  height: 100%;
}

#app {
  font-family: 'IBM Plex Sans', sans-serif;
  display: grid;
  background: whitesmoke;
}

.wrapper {
  margin: auto;
  text-align: center;
  background: lightgray;
  display: grid;
  
  box-shadow: 0em 0em 5em -1em rgba(0,0,0,0.3);
}

.content {
  display: grid;
  
  h1 {
    padding: 0.5em;
    font-weight: 300;
    font-style: italic;
  }
}

.home, .about {
  margin: auto;
}

.stuff {
  background: snow;
  padding: 2em;
  margin: 0em 1em 1em 1em;
  text-align: left;
  p {
    max-width: 500px;
  }
  img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
  }
}

nav {
  text-align: center;
  background: nth($clrs, 3);
  background-size: 5em;
  background-position: center; 
  background-color: #06d6a0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 28' width='56' height='28'%3E%3Cpath fill='%23ffd166' fill-opacity='0.5' d='M56 26v2h-7.75c2.3-1.27 4.94-2 7.75-2zm-26 2a2 2 0 1 0-4 0h-4.09A25.98 25.98 0 0 0 0 16v-2c.67 0 1.34.02 2 .07V14a2 2 0 0 0-2-2v-2a4 4 0 0 1 3.98 3.6 28.09 28.09 0 0 1 2.8-3.86A8 8 0 0 0 0 6V4a9.99 9.99 0 0 1 8.17 4.23c.94-.95 1.96-1.83 3.03-2.63A13.98 13.98 0 0 0 0 0h7.75c2 1.1 3.73 2.63 5.1 4.45 1.12-.72 2.3-1.37 3.53-1.93A20.1 20.1 0 0 0 14.28 0h2.7c.45.56.88 1.14 1.29 1.74 1.3-.48 2.63-.87 4-1.15-.11-.2-.23-.4-.36-.59H26v.07a28.4 28.4 0 0 1 4 0V0h4.09l-.37.59c1.38.28 2.72.67 4.01 1.15.4-.6.84-1.18 1.3-1.74h2.69a20.1 20.1 0 0 0-2.1 2.52c1.23.56 2.41 1.2 3.54 1.93A16.08 16.08 0 0 1 48.25 0H56c-4.58 0-8.65 2.2-11.2 5.6 1.07.8 2.09 1.68 3.03 2.63A9.99 9.99 0 0 1 56 4v2a8 8 0 0 0-6.77 3.74c1.03 1.2 1.97 2.5 2.79 3.86A4 4 0 0 1 56 10v2a2 2 0 0 0-2 2.07 28.4 28.4 0 0 1 2-.07v2c-9.2 0-17.3 4.78-21.91 12H30zM7.75 28H0v-2c2.81 0 5.46.73 7.75 2zM56 20v2c-5.6 0-10.65 2.3-14.28 6h-2.7c4.04-4.89 10.15-8 16.98-8zm-39.03 8h-2.69C10.65 24.3 5.6 22 0 22v-2c6.83 0 12.94 3.11 16.97 8zm15.01-.4a28.09 28.09 0 0 1 2.8-3.86 8 8 0 0 0-13.55 0c1.03 1.2 1.97 2.5 2.79 3.86a4 4 0 0 1 7.96 0zm14.29-11.86c1.3-.48 2.63-.87 4-1.15a25.99 25.99 0 0 0-44.55 0c1.38.28 2.72.67 4.01 1.15a21.98 21.98 0 0 1 36.54 0zm-5.43 2.71c1.13-.72 2.3-1.37 3.54-1.93a19.98 19.98 0 0 0-32.76 0c1.23.56 2.41 1.2 3.54 1.93a15.98 15.98 0 0 1 25.68 0zm-4.67 3.78c.94-.95 1.96-1.83 3.03-2.63a13.98 13.98 0 0 0-22.4 0c1.07.8 2.09 1.68 3.03 2.63a9.99 9.99 0 0 1 16.34 0z'%3E%3C/path%3E%3C/svg%3E");
  
  a {
    padding: 1em;
    display: inline-block;
    text-decoration: none;
    transition: background 0.2s;
    &:hover {
      background: nth($clrs, 2);
    }
  }
}
.active {
  background: nth($clrs, 2);
}

@media (max-width: 600px) {
  .stuff {
    margin: 0em;
    padding: 1em;
    p {
      max-width: 100vw;
    }
  }
  nav {
    a {
      padding: 1em 0em 1em 0em;
      width: 100%;
    }
  }
}
              
            
!

JS

              
                //UMD build of react-router-dom used
const {
  HashRouter,
  Switch,
  Route,
  NavLink
} = ReactRouterDOM

const About = () => (
  <div className="about">
    <h1>Something to read</h1>
    <div className = "stuff"><p>One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. "What's happened to me?" he thought. It wasn't a dream.</p></div>
  </div>
)

const Home = () => (
  <div className="home">
    <h1>Something to see</h1>
      <div className = "stuff">
        <img src="https://picsum.photos/300/?random" alt="Random Img"/>
      </div>
  </div>
)

const Main = () => (
  <div className = "content">
      <Route exact path='/' component={Home}/>
      <Route path='/about' component={About}/>
  </div>
)

// Navigation
const Navbar = () => (
    <nav>
      <NavLink to='/' activeClassName="active" exact={true}>Home</NavLink>
      <NavLink to='/about' activeClassName="active">About</NavLink>
    </nav>
)

const App = () => (
  <div className = "wrapper">
    <Navbar />
    <Main />
  </div>
)

ReactDOM.render((
  <HashRouter>
    <App />
  </HashRouter>
), document.getElementById('app'))

//trying other version
// https://cdnjs.cloudflare.com/ajax/libs/react/16.2.0/umd/react.development.js
// https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.2.0/umd/react-dom.development.js
// https://cdnjs.cloudflare.com/ajax/libs/react-router-dom/4.2.2/react-router-dom.js
// const {
//   BrowserRouter,
//   Route,
//   Link,
//   NavLink
// } = ReactRouterDOM

// const Home = () => (
//   <div class = "content-home">
//     <h2>Home</h2>
//     ...
//   </div>
// )

// const About = () => (
//   <div class = "content-about">
//     <h2>About</h2>
//     ...
//   </div>
// )

// const Stuff = () => (
//   <div class = "content-stuff">
//     <h2>Stuff</h2>
//     ...
//   </div>
// )

// ReactDOM.render(
//   <BrowserRouter>
//       <div class= "wrapper">
//         <div class = "navbar">
//           <NavLink  to="/" activeClassName="active" exact={true}  >Home</NavLink >
//           <NavLink  to="/about" activeClassName="active">About</NavLink >
//           <NavLink  to="/stuff" activeClassName="active">Stuff</NavLink >
//         </div>

//         <main>
//           {/*/boomerang required for codepen to open first page*/}
//           <Route path="/boomerang" component={Home} />
//           <Route exact path="/" component={Home} />
//           <Route path="/about" component={About} />
//           <Route path="/stuff" component={Stuff} />
//         </main>
//       </div>
//   </BrowserRouter>,document.getElementById('app'));

              
            
!
999px

Console