cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

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

body {
  background-color: #FF5E3A;
  padding: 20px;
}

.demo__container {
  background-color: white;
  padding: 10px 10px 0;
  position: relative;
  overflow: hidden;
}

.demo__logo {
  background-color: #C1C1C1;
  margin: 0 auto;
  width: 30px;
  height: 30px;
}

.demo__intro {
  margin-top: 10px;
  margin-bottom: 10px;
}

.demo__line {
  height: 6px;
  background-color: #C1C1C1;
  margin-bottom: 6px;
  &:last-child {
    margin-bottom: 0;
  }
}

.demo__line-1 {
  width: 70%;
}

.demo__line-2 {
  width: 80%;
}

.demo__line-3 {
  width: 30%;
}

.demo__list {}

.demo__item {
  margin-bottom: 10px;
}

.demo__item--feature {}

.demo__item-pic {
  height: 100px;
  padding: 10px;
  background-color: #FF9500;
  font-size: 16px;
}

.demo__item-content {
  height: 100px;
  background-color: #C1C1C1;
}

.demo__container.middle {
  .demo__logo {
    margin: 0;
    float: left;
  }

  .demo__intro {
    margin: 0 0 10px 40px;
  }

  .demo__item {
    height: 100px;
  }

  .demo__item-pic {
    width: 100px;
    float: left;
  }
}

.demo__container.wide {
  .demo__list {
    margin-right: -10px;
  }

  .demo__item {
    margin-right: 10px;
    width: calc(50% - 10px);
    float: left;
    height: auto;
  }

  .demo__item--feature {
    height: 100px;
    width: calc(100% - 10px);
    .demo__item-pic {
      width: 100px;
      float: left;
    }
  }

  .demo__item-pic {
    float: none;
    width: 100%;
  }
}

.example__btn {
  color: #333;
  background-color: #fff;
  border-color: #ccc;
  display: inline-block;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.42857143;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  touch-action: manipulation;
  cursor: pointer;
  user-select: none;
  background-image: none;
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
  transition: all 200ms;
  box-shadow: 0 4px 0 #ccc,0 5px 5px 1px rgba(0,0,0,0.4);
  position: relative;
  top: -4px;
  display: block;
  margin-bottom: 10px;
}

.example__btn--active {
  background-color: #1D62F0;
  color: white;
  top: 1px;
  box-shadow: 0 1px 0 #0a3a9d,0 1px 1px 1px rgba(0,0,0,0.4);
}

            
          
!
            
              const Motion = ReactMotion.Motion;

const MIM_WIDTH = 100;
const LAYOUTS = [160, 265, 310];

const Demo = React.createClass({
  render() {
    const items = [0,1,2,3,4].map((n) => (
      <li className={ classNames('demo__item', {'demo__item--feature': n === 0}) } >
        <div className='demo__item-pic'></div>
        <div className='demo__item-content'></div>
      </li>
    ));

    const width = this.props.width;
    
    console.log(this.props)

    return (
      <Motion defaultStyle={{ width }} style={{ width: ReactMotion.spring(width, [120, 11]) }}>{(values) => (
        <div className={classNames('demo__container', this.props.containerQuery)} style={{ width: `${values.width}px` }}>
          <div className='demo__logo'></div>
          <div className='demo__intro'>
            <div className='demo__line demo__line-1'></div>
            <div className='demo__line demo__line-2'></div>
            <div className='demo__line demo__line-3'></div>
          </div>
          <ol className='demo__list'>{ items }</ol>
        </div>
      )}</Motion>
    );
  }
});

const query = {
  middle: {
    minWidth: 250
  },
  wide: {
    minWidth: 300
  },
};

const Container = ReactContainerQuery.applyContainerQuery(Demo, query);

class Button extends React.Component {
  render() {
    const { isActive, children } = this.props;

    return (
      <button className={classNames('example__btn', {'example__btn--active': isActive})} onClick={this.props.onClick}>
        {children}
      </button>
    );
  }
}

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {layout: 0};
  }

  render() {
    return (
      <div className='container'>
        <div className='controls'>
          <Button onClick={() => this.selectLayout(0)} isActive={this.state.layout === 0} >width &lt; 250</Button>
          <Button onClick={() => this.selectLayout(1)} isActive={this.state.layout === 1} >250 &lt; width &lt; 300</Button>
          <Button onClick={() => this.selectLayout(2)} isActive={this.state.layout === 2} >300 &lt; width</Button>
        </div>
        <Container width={LAYOUTS[this.state.layout]} />
      </div>
    );
  }

  selectLayout(n) {
    this.setState({layout: n});
  }
}

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

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console