123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div id="header">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu ligula nec ipsum malesuada tristique. Phasellus ac lorem ac nisl congue commodo a eget magna. Proin sit amet pretium magna. Curabitur luctus, sapien ut laoreet lacinia, elit orci dictum.</p>
</div>
<div class="post-body" >
  <p>Lorem #ipsum dolor sit amet, @consectetur adipiscing elit. Praesent eu ligula nec ipsum malesuada tristique. Phasellus ac lorem ac nisl congue commodo a eget magna. Proin sit amet pretium magna. Curabitur luctus, sapien ut laoreet lacinia, elit orci dictum
    ligula, nec luctus ex diam eu purus. Suspendisse sem nisi, commodo ut elit a, facilisis congue ex. Praesent consequat volutpat odio, et faucibus arcu dignissim nec. Praesent hendrerit condimentum imperdiet. Suspendisse molestie ipsum ipsum, in venenatis
    nibh aliquam vitae. Proin congue arcu et augue auctor vehicula. Sed mattis arcu a tempor auctor.</p>
  <p>Curabitur elementum, purus vitae pretium suscipit, magna ligula elementum tellus, ut lacinia lacus odio eget arcu. Aenean cursus eros quis nisi viverra sagittis. Aenean purus sapien, pharetra quis suscipit nec, lobortis nec augue. Cras euismod sagittis
    ex, non tincidunt massa lobortis eget. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu ligula nec ipsum malesuada tristique. Phasellus ac lorem ac nisl congue commodo a eget magna. Proin sit amet pretium magna. Curabitur luctus, sapien ut laoreet lacinia, elit orci dictum
    ligula, nec luctus ex diam eu purus. Suspendisse sem nisi, commodo ut elit a, facilisis congue ex. Praesent consequat volutpat odio, et faucibus arcu dignissim nec. Praesent hendrerit condimentum imperdiet. Suspendisse molestie ipsum ipsum, in venenatis
    nibh aliquam vitae. Proin congue arcu et augue auctor vehicula. Sed mattis arcu a tempor auctor.</p>
  <p>Curabitur elementum, purus vitae pretium suscipit, magna ligula elementum tellus, ut lacinia lacus odio eget arcu. Aenean cursus eros quis nisi viverra sagittis. Aenean purus sapien, pharetra quis suscipit nec, lobortis nec augue. Cras euismod sagittis
    ex, non tincidunt massa lobortis eget. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu ligula nec ipsum malesuada tristique. Phasellus ac lorem ac nisl congue commodo a eget magna. Proin sit amet pretium magna. Curabitur luctus, sapien ut laoreet lacinia, elit orci dictum
    ligula, nec luctus ex diam eu purus. Suspendisse sem nisi, commodo ut elit a, facilisis congue ex. Praesent consequat volutpat odio, et faucibus arcu dignissim nec. Praesent hendrerit condimentum imperdiet. Suspendisse molestie ipsum ipsum, in venenatis
    nibh aliquam vitae. Proin congue arcu et augue auctor vehicula. Sed mattis arcu a tempor auctor.</p>
  <p>Curabitur elementum, purus vitae pretium suscipit, magna ligula elementum tellus, ut lacinia lacus odio eget arcu. Aenean cursus eros quis nisi viverra sagittis. Aenean purus sapien, pharetra quis suscipit nec, lobortis nec augue. Cras euismod sagittis
    ex, non tincidunt massa lobortis eget. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu ligula nec ipsum malesuada tristique. Phasellus ac lorem ac nisl congue commodo a eget magna. Proin sit amet pretium magna. Curabitur luctus, sapien ut laoreet lacinia, elit orci dictum
    ligula, nec luctus ex diam eu purus. Suspendisse sem nisi, commodo ut elit a, facilisis congue ex. Praesent consequat volutpat odio, et faucibus arcu dignissim nec. Praesent hendrerit condimentum imperdiet. Suspendisse molestie ipsum ipsum, in venenatis
    nibh aliquam vitae. Proin congue arcu et augue auctor vehicula. Sed mattis arcu a tempor auctor.</p>
  <p>Curabitur elementum, purus vitae pretium suscipit, magna ligula elementum tellus, ut lacinia lacus odio eget arcu. Aenean cursus eros quis nisi viverra sagittis. Aenean purus sapien, pharetra quis suscipit nec, lobortis nec augue. Cras euismod sagittis
    ex, non tincidunt massa lobortis eget. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu ligula nec ipsum malesuada tristique. Phasellus ac lorem ac nisl congue commodo a eget magna. Proin sit amet pretium magna. Curabitur luctus, sapien ut laoreet lacinia, elit orci dictum
    ligula, nec luctus ex diam eu purus. Suspendisse sem nisi, commodo ut elit a, facilisis congue ex. Praesent consequat volutpat odio, et faucibus arcu dignissim nec. Praesent hendrerit condimentum imperdiet. Suspendisse molestie ipsum ipsum, in venenatis
    nibh aliquam vitae. Proin congue arcu et augue auctor vehicula. Sed mattis arcu a tempor auctor.</p>
  <p>Curabitur elementum, purus vitae pretium suscipit, magna ligula elementum tellus, ut lacinia lacus odio eget arcu. Aenean cursus eros quis nisi viverra sagittis. Aenean purus sapien, pharetra quis suscipit nec, lobortis nec augue. Cras euismod sagittis
    ex, non tincidunt massa lobortis eget. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu ligula nec ipsum malesuada tristique. Phasellus ac lorem ac nisl congue commodo a eget magna. Proin sit amet pretium magna. Curabitur luctus, sapien ut laoreet lacinia, elit orci dictum
    ligula, nec luctus ex diam eu purus. Suspendisse sem nisi, commodo ut elit a, facilisis congue ex. Praesent consequat volutpat odio, et faucibus arcu dignissim nec. Praesent hendrerit condimentum imperdiet. Suspendisse molestie ipsum ipsum, in venenatis
    nibh aliquam vitae. Proin congue arcu et augue auctor vehicula. Sed mattis arcu a tempor auctor.</p>
  <p>Curabitur elementum, purus vitae pretium suscipit, magna ligula elementum tellus, ut lacinia lacus odio eget arcu. Aenean cursus eros quis nisi viverra sagittis. Aenean purus sapien, pharetra quis suscipit nec, lobortis nec augue. Cras euismod sagittis
    ex, non tincidunt massa lobortis eget. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
  
</div>

Esto está fuera del div class="post-body"
            
          
!
            
              #header {
  width: 100%;
  background: #eee;
}
.post-body {
position: relative !important;
}
#pajarito {
  display: none;
  position: absolute;
  width: 25px;
  height: 25px;
  margin: -2em 2em 0 0;
  background: url(https://1.bp.blogspot.com/-DXICtW2x5No/VaKmEex2NNI/AAAAAAAAUNU/Jl1QOtvSJgU/s1600/twitter.png) white;
  border: solid .2em #0CB7F2;
  border-radius: 100%;
  cursor: pointer;
}
#pajarito:hover {
  background-color: #eee;
}
            
          
!
            
              var seleccionado = '';
var horiz, vert, referencia;
function carga() {
  referencia = document.getElementsByClassName('post-body')[0]
  var pajarito = document.createElement('span');
  pajarito.setAttribute('id', 'pajarito');
  pajarito.setAttribute('onmousedown', 'abre()');
  referencia.appendChild(pajarito);
  referencia.onmouseup = captura;
}

function captura(e) {
  seleccionado = (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text);
  if (seleccionado != '') {  
    horiz= ((e.x) ? e.x : e.clientX) ;
    vert= ((e.y) ? e.y : e.clientY) ;
    document.getElementById('pajarito').style.display = 'inline-block';
    document.getElementById('pajarito').style.left = horiz + 'px';
    document.getElementById('pajarito').style.top = vert + 'px';
  } else {
    document.getElementById('pajarito').style.display = 'none';
  }
}

function abre() {
  var origen = window.location.href;
  var mensaje = seleccionado.toString().substring(0, 100).replace('#','%23');  
  var direccion = 'https://twitter.com/intent/tweet?status=' + mensaje + ' ' + origen;
  window.open(direccion, '', 'width=500,height=500');
}

onload = carga;

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console