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

              
                <div id='app'/>
              
            
!

CSS

              
                $darkGrey: #3c3c3b
$darkPaleNavy: #53525e
$lightBlue: #d3f6f3
$lightYellow: #f9fce1
$lightOrange: #fee9b2
$pastelOrange: #fbd1b7

body
  font-family: 'Oswald', sans-serif

.scrollingContainer
  overflow-y: scroll
  scroll-behavior: smooth

.section
  height: 100vh
  width: 100%
  color: $darkPaleNavy
  font-size: 5em
  display: flex
  justify-content: center
  align-items: center
  background-color: $lightBlue
  &:nth-child(2)
    background-color: $lightYellow
  &:nth-child(3)
    background-color: $lightOrange
  &:nth-child(4)
    background-color: $pastelOrange

.floating
  position: relative
  
.contextMenu
  width: 2.5em
  height: 2.5em
  border-radius: 50%
  background-color: $darkGrey
  position: fixed
  cursor: pointer
  bottom: 0
  margin: 1em
  z-index: 1
  
.menu
  position: fixed
  bottom: 0
  margin: 2.5em 4em 4em
  z-index: 1
  display: flex
  flex-flow: column
  
.menu > a
  background-color: $darkGrey
  color: white
  width: 150px
  padding: 0.5em
  text-align: center
  transform: translateY(-2.5em)
  transition: transform 400ms 0ms, opacity 400ms ease-out
  opacity: 1
  border-radius: 8pt
  text-decoration: none
  &:nth-child(2)
    transform: translateY(-1.5em)
    transition: transform 300ms 0ms, opacity 300ms ease-out
  &:last-child
    transform: translateY(-0.5em)
    transition: transform 200ms 0ms, opacity 200ms ease-out
  
.hideMenu
  position: fixed
  bottom: 0
  margin: 2.5em 4em
  display: flex
  flex-flow: column
  
.hideMenu > a
  background-color: $darkPaleNavy
  color: white
  width: 150px
  padding: 0.5em
  text-align: center
  visibility: none
  transform: translateY(4em)
  transition: transform 400ms 0ms, opacity 400ms ease-in
  opacity: 0
  border-radius: 8pt
  text-decoration: none
  &:nth-child(2)
    transform: translateY(2em)
    transition: transform 300ms 0ms, opacity 300ms ease-in
  &:last-child
    transform: translateY(0em)
    transition: opacity 200ms ease-in
  
              
            
!

JS

              
                class ContextMenu extends React.Component {
  constructor(props) {
    super(props)
  }
  
  handleMenuClicked = (event) => {
    event.preventDefault()
    this.props.onMenuClicked()
  }
  
  render() {
    const {isMenuOpened} = this.props
    return(
      <>
          <nav className={isMenuOpened ? 'menu' :'hideMenu'}>
            <a href="#4">Jump to 4</a>
            <a href="#3">Jump to 3</a>
            <a href="#2">Jump to 2</a>
          </nav>
         
        <div onClick={this.handleMenuClicked} className='contextMenu'/>
      </>
    )
  }
}

class App extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      isMenuOpened: false
    }
  }
  
  onMenuClicked = () => {
    this.setState({
      isMenuOpened: !this.state.isMenuOpened
    })
  }
  
  render() {
    const {isMenuOpened} = this.state
    return (
      <div className='scrollingContainer'>
        <div className='section' id='1'>SECTION 1</div>
        <div className='section' id='2'>SECTION 2</div>
        <div className='section' id='3'>SECTION 3</div>
        <div className='section' id='4'>SECTION 4</div>
        <div className='floating'>
          <ContextMenu isMenuOpened={isMenuOpened} onMenuClicked={this.onMenuClicked}/>
        </div>
      </div>
    )
  }
}

ReactDOM.render(<App/>, document.getElementById('app'))
              
            
!
999px

Console