Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                html {
  background: #ccc;
  font-family: 'Droid Serif', serif;
  font-size: 13px;
  line-height: 1.3;
}

.content {
  overflow: scroll;
  resize: both;
  padding: 1rem;
  width: 260px;
  height: 80vh;
  background: #CB4338;
  color: #fcf3bb;
}

img {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  width: 100%;
  float: left; 
  margin: 0 1rem 1rem 0;
}

.column-copy {
  columns: auto 200px;
  column-gap: 2rem;
  padding: 1rem 0;
  p {
    margin: 0 0 1rem 0;
  }
}

.controls {
  width: 260px;
  background: white;
  padding: 1rem;
  z-index: 1;
  position: absolute;
  bottom: 1rem;
  right: 1rem;
}
.handle {
  background: black;
  color: white;
  text-align: center;
}

h1 {
  font-family: 'Playfair Display', serif;
  strong {
    font-weight: 900;
    display: block;
    text-transform: uppercase;
  }
}

.by {
  padding: 0.5rem;
  border-top: 2px solid #ec6164;
  border-bottom: 2px solid #ec6164;
}

h1 {
  font-size: 1.8rem;
  margin: 0 0 1rem 0;
  strong {
    font-size: 3rem;
  }
}

label {
  display: block;
}
body style {
  display: block;
  background: #333;
  color: white;
  white-space: pre;
  padding: 10px;
  font-family: monospace;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
}
.all-properties {
  margin: 0 0 1rem 0;
  font-family: monospace;
}
              
            
!

JS

              
                console.clear();

var Draggable = window.ReactDraggable;

class Content extends React.Component {
  render() {
    return(
      <div className="example-content">
        <h1><strong>Срочно в номер!</strong> Печатную полосу подстерегает пред&shy;­сказанная проблема</h1>
        <div className="by">
          Кристофер Кривоколессоу
        </div>
        
        <p>Переносы строк на странице довольно сложны. Есть ряд CSS-свойств, которые говорят, как переносить строки. Здесь замешаны браузерные префиксы, альтернативные названия свойств, выбор значений и кроссбраузерная поддержка. Возможно, однажды нам станет легче.</p>
        <p>Никотинамидадениндинуклеотидфосфатполимераза.</p>
        <p>https://fruitcakesandbakingingeneral.foodfoodiefooed.food</p>
        
        <p>Это даже не касается других связаных с этим вещей: &lt;br&gt;, &lt;wbr&gt; и &shy;.</p>
        
        <p>次の単語グレートブリテンおよび北アイルランド連合王国で本当に大きな言葉</p>
      <div className="column-copy">        
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere quis corrupti minus doloribus sunt perspiciatis sequi quasi ratione voluptas magni, quos dignissimos sint, repellendus id voluptatum ducimus atque eius. Sequi doloribus iusto cupiditate. animi optio nulla nobis, totam quasi repellat ab! Quos excepturi at consequuntur quibusdam eius? Harum, iure!</p>
<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/paperboy.png' alt='' />
<p>Possimus voluptatum eius ea doloremque iusto minima quasi tempore architecto voluptates, sit inventore libero, illum autem a sequi adipisci quod. Vero et cum nemo aspernatur aliquid temporibus iure reiciendis ratione dicta. Sit, dicta blanditiis quis doloribus beatae id reprehenderit atque aliquid laborum iusto illum praesentium tenetur labore! Incidunt minima nam consectetur officia assumenda dignissimos a vero beatae architecto magni nostrum ratione cum eos, officiis, quis cupiditate! Accusantium dolorem soluta exercitationem enim consequuntur, corrupti quidem voluptatibus odio veniam voluptatum possimus in?</p>
<p>Deleniti vitae voluptatibus incidunt labore vero distinctio odio praesentium dolorem hic quo. Aperiam corporis sint nostrum consequuntur esse. Quidem, quisquam tempora praesentium, ipsam rerum voluptatem ducimus est amet maxime eum minus nulla illo fugit doloribus impedit laudantium inventore distinctio tempore.</p>
      </div>
      </div>
    );
  }
}

class PropertyChoices extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      styles: {
        'word-break: break-all;': false,
        'word-break: break-word;': false,
        'word-break: keep-all;': false,
        'overflow-wrap: break-word;': false,
        'hyphens: manual;': false,
        'hyphens: auto;': false,
        'line-break: loose;': false,
        'line-break: strict;': false,
        'line-break: anywhere;': false,
        'text-wrap: balance;': false
      }
    };
  }
  
  componentDidUpdate() {
    // React hates this.
    // StyleFix.styleAttribute(
    //   document.querySelector("#style")
    // );
  }
  
  toggleCheckbox(e) {
    let property = e.target.parentElement.textContent;
    this.setState({
      styles: {
        ...this.state.styles,
        [property]: !this.state.styles[property]
      }
    });
  }
  
  render() {
    var _this = this;
    
    let allStyles = ``;
    Object.keys(this.state.styles).map(function(key) {
      if (_this.state.styles[key]) {
        if (key === 'hyphens: auto;') {
          allStyles += '  -webkit-hyphens: auto;\n  -moz-hyphens: auto;\n  -ms-hyphens: auto;\n  hyphens: auto;\n';
        } else if (key === 'hyphens: manual;') {
          allStyles += '  -webkit-hyphens: manual;\n  -moz-hyphens: manual;\n  -ms-hyphens: manual;\n  hyphens: manual;\n';
        } else if (key === 'overflow-wrap: break-word;') {
          allStyles += '  word-wrap: break-word;\n  overflow-wrap: break-word;\n';
        } else {
          allStyles += "  " + key + "\n";
        }
        
      }
    });
    
    return(
      <div>
        <Draggable handle=".handle">
          
          <form className="controls">
            <div className="handle">Тащи меня</div>
            <h2>Свойства, связанные с переносами строк</h2>

            <div className="all-properties">
            {Object.keys(this.state.styles).map(function(key, i) {
              return(
                <label key={i}>
                  <input type="checkbox" 
                    checked={_this.state.styles[key]}
                    onChange={_this.toggleCheckbox.bind(_this)}
                  />
                  {key}
                </label>
              );
            })}
            </div>

          </form>
        </Draggable>

        <style id="style" contentEditable dangerouslySetInnerHTML={{
          __html: 
`body {
${allStyles}}`
          }} />
        
      </div>
    );
  }
}

ReactDOM.render(
  <div className="grid">
    <div className="choices">
      <PropertyChoices />
    </div>
    <div className="content">
      <Content />
    </div>
  </div>
, document.querySelector("#app"));

              
            
!
999px

Console