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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="target"></div>

              
            
!

CSS

              
                @import 'https://fonts.googleapis.com/css?family=Hind+Madurai|Rakkas';

$size: 8.33;

body {
  font-family: Hind Madurai;
  font-size: 2.8vmin;  
}

.app {
  width: 100vw;
  min-height: 100vh;
}

.modes {
  width: 100vmin;
  margin: auto;
}

.container {
  padding: 4vmin;  
  margin-bottom: 7vmin;
  display: inline-block;  
  height: $size * 2 + vmin;
  width: $size * 3 + vmin;
  position: relative;
}

.circle {
  padding: $size + vmin;
  border-radius: $size + vmin;
  width: 0;
  cursor: pointer;
}

.right {
  background-color: blue;
  position: relative;    
  left: $size + vmin;  
}

.left {
  background-color: orange;
  position: relative;  
  top: $size * -2 + vmin;
}

.label {
  width: $size * 4 + vmin;
  position: absolute;
  bottom: -2vmin;
  left: 0;
  text-align: center;
}

.header {
  .title {
    width: 70vmin;  
    margin: auto;    
    font-family: Rakkas;
    font-size: 9vmin;
    text-align: center;
    border-bottom: 0.8vmin solid black;
    margin-bottom: 6vmin;
    padding-top: 10vmin;
    line-height: 8vmin;
  }
}

.copy {
  width: 92vmin;  
  margin: auto;    
  padding-bottom: 5vmin;
}

.footer {
  text-align: center;
}

.color-picker {
  position: fixed;  
  opacity: 0;
  top: -100px;
}

a {
  color: inherit;
  &:hover {
    opacity: 0.5;
  }
}

              
            
!

JS

              
                const ColorPicker = React.createClass({ 
  render() {
    const {color, onChange, name, active} = this.props;
    if (active) {
      this._input.click();
    }
    const onChangeWrapped = (event) => onChange(name, event.target.value);
    return <input
             className="color-picker"
             type="color"
             onChange={onChangeWrapped}
             value={color}
             ref={input => this._input = input}/>;
  },
});

const App = React.createClass({
  getInitialState() {
    return {
      pickerActive: false,
      pickerTargetName: 'backgroundColor',
      backgroundColor: '#f1f1f1',      
      leftColor: "#EB7F00",
      rightColor: "#225378",
    };
  },
  changeColor(name, color) {
    console.log(name, color);
    this.setState({
      [name]: color,
      pickerTargetName: name,
      pickerActive: false,
    });
  },
  handleClick(name) {
    this.setState({
      pickerTargetName: name,
      pickerActive: true,
    });
  },
  render() {
    return <div className="app" onClick={this.clickHandler}
             style={{backgroundColor: this.state.backgroundColor}}>
      <Header handleClick={this.handleClick}/>
      <ColorPicker
        onChange={this.changeColor}
        name={this.state.pickerTargetName}
        color={this.state[this.state.pickerTargetName]}
        active={this.state.pickerActive}/>

      <div className="modes">
      {
        blendModes.map(mode =>
          <Container mode={mode}
            handleClick={this.handleClick}
            leftColor={this.state.leftColor}
            rightColor={this.state.rightColor}
            />
        )
      }
      </div>
      <div className="footer copy">
        <a href="https://codepen.io/chrisbolin">codepen.io/chrisbolin</a>
        {' | '}
        <a href="https://twitter.com/bolinchris">@bolinchris</a>
        {' | '}        
        apologies to <a href="https://www.youtube.com/watch?v=lAl28d6tbko">blendtec</a>
      </div>
    </div>
  },
});

const Container = ({mode, rightColor, leftColor, handleClick}) => {
  return <div className="container">
      <div className="circle right"
        onClick={handleClick.bind(null, 'rightColor')}
        style={{backgroundColor: rightColor}}/>
      <div className="circle left"
        onClick={handleClick.bind(null, 'leftColor')}
        style={{mixBlendMode: mode, backgroundColor: leftColor}}/>
      <div className="label">{mode}</div>
    </div>
  ;
};

const Header = ({handleClick}) => {
  return <div className="header">
    <div className="title">
      How Will it Blend?
    </div>
    <div className="copy">
      The CSS property <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode">mix-blend-mode</a> controls how an element blends into elements behind it. All 16 blend modes are show below, and apply to
      the <a href="#" onClick={handleClick.bind(null, 'leftColor')}>left circle</a>, which overlaps with the <a href="#" onClick={handleClick.bind(null, 'rightColor')}>right circle</a> and
      the <a href="#" onClick={handleClick.bind(null, 'backgroundColor')}>background</a>.
    </div>    
  </div>
  ;
};

const blendModes = [
  'normal',
  'overlay',  
  'exclusion', 
  'hard-light',
  'soft-light',  
  'screen',
  'difference',
  'color-dodge',
  'color-burn',
  'multiply',
  'hue',
  'saturation',
  'darken',
  'lighten',
  'color',  
  'luminosity',
];

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

Console