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

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

              
                <body>
<header>
<img src="" alt="" />
<input type="search" placeholder="type to search (functional)" autofocus id="search" />
</header>
<textarea id="newPost" placeholder="What's up? (press enter to post)"></textarea>
<div id="container">
  <div class="post">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas doloribus nam quaerat, incidunt, accusamus tenetur dolorum provident architecto veniam.
    <div class="comments">
      <input type="text" placeholder="type a new comment" class="newComment" />
      <div class="comment">Lorem ipsum dolor sit amet.</div>
      <div class="comment">Lorem ipsum dolor sit amet.</div>
       <div class="comment">Lorem ipsum dolor sit amet.</div>
      <div class="comment">Lorem ipsum dolor sit amet.</div>
      <div class="comment">Lorem ipsum dolor sit amet.</div>
    </div>    
  </div>
</div>
</body>
              
            
!

CSS

              
                *{
  box-sizing: border-box;
  padding: 20px;
  font-family: Helvetica, Calibri;
  font-size: 16px;
  line-height: 1.5em;
  font-weight: lighter;
}
body{
  background-image: url("https://download.unsplash.com/photo-1421091242698-34f6ad7fc088");
  background-position: right center;
  background-attachment: fixed;
}
header{
  top: -20px;
  left: -20px;
  width: 100%;
  height: 110px;
  position: fixed;
  margin: 20px;
  background: #3498db;
  z-index: 100;
//  border-bottom: 5px solid #2980b9;
}
input[type=search], textarea, input[type=text]{
  -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
}
#search{
top: 30px;
  border-radius: 3px;
border: 1px solid #2980b9;
padding: 7px;
color: white;
font-size: 1.4em;
background: #2980b9;
font-weight: lighter;
width: 500px;
position: fixed;
left: calc(50% - 250px);
@media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : landscape) 
    and (-webkit-min-device-pixel-ratio : 2){
      width: 80%;
      left: 10%;
    }

  @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : portrait) 
    and (-webkit-min-device-pixel-ratio : 2){
      width: 80%;
      left: 10%;
    }
}

#container{
  top: 300px;
  position: absolute;
  left: calc(50% - 250px);
  //border: 5px solid gray;
  width: 500px;
  height: auto;
  padding: 0px;
  @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : landscape) 
    and (-webkit-min-device-pixel-ratio : 2){
      width: 90%;
      left: 5%;
    }

  @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : portrait) 
    and (-webkit-min-device-pixel-ratio : 2){
      width: 90%;
      left: 5%;
    }
}
.post{
  background: white;
  margin-bottom: 20px;
  padding: 20px;
  font-size: 1.4em;
  //border: 1px solid #aaa;
  box-shadow: .5px .5px 2px #aaa;
}
.comments{
  padding: 0px;
  //border: 2px solid black;
  
  input{
    border: none;
    border-bottom: 1px solid #eee;
    display: block;
    padding: 10px;
    padding-bottom: 2px;
    margin-top: 10px;
    margin-bottom: 15px;
    font-size: 1.2em;
    font-weight: lighter;
    width: 100%;
  }
}
.comment{
  font-size: 1.2em;
  padding: 10px;
  margin-top: 10px;
  width: 100%;
  cursor: pointer;
}
.comment:nth-child(odd){
  background: #efefef;
  padding-top: 12.5px;
  padding-bottom: 12.5px;
}
.comment:nth-child(even){
  padding-bottom: 2.5px;
  padding-top: 2.5px;
}
#newPost{
  border: 1px dashed #aaa;
    resize: none;
    padding: 20px;
    margin-top: 85px;
   background: rgba(255,255,255,0.8);
    font-size: 1.4em;
    font-weight: lighter;
    width: 500px;
    position: absolute;
    left: calc(50% - 250px);
    height: 150px;
    @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : landscape) 
    and (-webkit-min-device-pixel-ratio : 2){
      width: 90%;
      left: 5%;
    }

  @media only screen 
    and (min-device-width : 375px) 
    and (max-device-width : 667px) 
    and (orientation : portrait) 
    and (-webkit-min-device-pixel-ratio : 2){
      width: 90%;
      left: 5%;
    }
}

//Highlighting
.highlight {
    background-color: #fff34d;
    font-size: inherit;
}

.highlight {
    padding:1px 4px;
    margin:0 -4px;
}

//Change placeholder color
.newComment::-webkit-input-placeholder { /* WebKit browsers */
    color: #2980b9;
    opacity: .7;
}
.newComment:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
   color:    #2980b9;
   opacity:  .7;
}
#search::-webkit-input-placeholder{
  color: #19B5FE;
}
              
            
!

JS

              
                $("#container").on('keyup', '.newComment', function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
 if(code == 13) { //Enter keycode
   $(this).parent().append('<div class="comment" hidden>' + $(this).val() + '</div>');
   $(this).val('');
   $(".comment").fadeIn(400);
 }
});

$('#newPost').keyup(function(e){
var code = (e.keyCode ? e.keyCode : e.which);
  if($(this).val().length > 1 && code == 13) { //Enter keycode
   e.preventDefault();
    e.stopPropagation();
    $('#container').prepend('<div class="post" hidden>' + $(this).val() + '<div class="comments"><input type="text" placeholder="type a new comment" class="newComment"/>' + '</div>');
   $(this).val('');
   $(".post").fadeIn(400); 
 }
});

//Search
$('#search').keyup(function(e){
  var term = $(this).val();
  $('#container').removeHighlight();
  if(term){
    $('#newPost').hide();
 		$('#container').css('top', 130);
    $(".post").each(function(){
      if($(this).text().toLowerCase().indexOf(term.toLowerCase()) < 0)
        $(this).hide();
      else
        $(this).show();
    });
 $('.post').highlight(term);
  }
  else{
    $('*').show();
    $('#container').css('top', 300);
  }
  });

//Search highlighting - from https://gist.github.com/jonraasch/563055
jQuery.fn.highlight = function(pat) {
 function innerHighlight(node, pat) {
  var skip = 0;
  if (node.nodeType == 3) {
   var pos = node.data.toUpperCase().indexOf(pat);
   if (pos >= 0) {
    var spannode = document.createElement('span');
    spannode.className = 'highlight';
    var middlebit = node.splitText(pos);
    var endbit = middlebit.splitText(pat.length);
    var middleclone = middlebit.cloneNode(true);
    spannode.appendChild(middleclone);
    middlebit.parentNode.replaceChild(spannode, middlebit);
    skip = 1;
   }
  }
  else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
   for (var i = 0; i < node.childNodes.length; ++i) {
    i += innerHighlight(node.childNodes[i], pat);
   }
  }
  return skip;
 }
 return this.each(function() {
  innerHighlight(this, pat.toUpperCase());
 });
};
 
jQuery.fn.removeHighlight = function() {
 function newNormalize(node) {
    for (var i = 0, children = node.childNodes, nodeCount = children.length; i < nodeCount; i++) {
        var child = children[i];
        if (child.nodeType == 1) {
            newNormalize(child);
            continue;
        }
        if (child.nodeType != 3) { continue; }
        var next = child.nextSibling;
        if (next == null || next.nodeType != 3) { continue; }
        var combined_text = child.nodeValue + next.nodeValue;
        new_node = node.ownerDocument.createTextNode(combined_text);
        node.insertBefore(new_node, child);
        node.removeChild(child);
        node.removeChild(next);
        i--;
        nodeCount--;
    }
 }
 
 return this.find("span.highlight").each(function() {
    var thisParent = this.parentNode;
    thisParent.replaceChild(this.firstChild, this);
    newNormalize(thisParent);
 }).end();
};

$("#container").on('click', '.comment', function(e) {
  $(this).remove();
});

              
            
!
999px

Console