cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

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.

            
              header 
   h1 Z Browser
   
   
.z-browser
.z-browser(data-url="http://caradeuc.info") 

      
      
footer
   h4 by &copy; Benjamin Caradeuc
            
          
!
            
              $bg : #D8D9DB;
$shadow : 0 0 50px rgba(0,0,0, 0.3);
$borders : 1px solid rgba(0,0,0, 0.5);
$borderad : 0.4rem;
$greyg : linear-gradient(#eee, #bbb);
$shadow-inset: 0 3px 6px -3px rgba(0, 0, 0, 0.3) inset;

*, *:before, *:after{
   margin:0;
   padding:0;
   box-sizing:border-box;
}
html{
   font-size: 16px;
}
body{
   font-size:1rem;
   background: $bg;
   font-family: Sans-Serif;
}

header, footer{
   color:white;
   text-align:center;
   padding:1rem;
   font-weight: lighter;
}

.z-browser{
   overflow:hidden;
   width: 80%;
   background: #fff;
   border:$borders;
   border-radius: $borderad;
   margin:1rem auto;
   box-shadow:$shadow;
      
   .ctrls{
      height:3rem;
      background: #ddd;
      background-image: $greyg;
      border-bottom: $borders;
      position:relative;
      
      .ctrl-btn{
         cursor: not-allowed; 
         position:absolute;
         display:block;
         height:1.8rem;
         width:4.5rem;
         top:0.6rem;
         left:0.7rem;
         background: $greyg;
         border-radius:$borderad/2;
         border: $borders;
         font-size:0;
         
         & div{
            display:inline-block;
            position:relative;
            height:100%;
            width:50%;
            font-size:1rem;
            
            &.previous{
               border-right: 1px solid #aaa;
            }
            &:before{
               content:"";
               position: absolute;
               display:block;
               width:0;
               height:0;
               top:0.5rem;
               left:0.7rem;
            }
            &.previous:before{
               border:.35rem solid transparent;
               border-left:none;
               border-right:.7rem solid #777;
            }
            &.next:before{
               border:.35rem solid transparent;
               border-right:none;
               border-left:.7rem solid #777;
            }
         }
      }
         
      .bar{
         position:absolute;
         left: 6rem;
         top: 0.6rem;
         height:1.8rem;
         right:0.7rem;
         background: #fff;
         border-radius:$borderad/2;
         border:$borders;
         box-shadow: $shadow-inset;
         padding:0 2rem 0 0;
         
         .address{
            width:100%;
            display:block;
            height:100%;
            border:none;
            outline:none;
            padding: 0 0.6rem;
            background: transparent;
         }
         
         .reload {
            position:absolute;
            right:0.3rem;
            top:0.2rem;
            display:block;
            
            &:before{
               cursor:pointer;
               content:  url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAVCAQAAADhwnZkAAACHElEQVQoz31SS0wTURQdUBqgiYoQDW5MTCQhWMWFaUxs4sKlq+5McKe77liSQEJYy8qYdminxVJKhxqnBWxpmH4cOlQ7jZbph6al+BxDUjMJK1oRe30z/QQbw32rd9455/4eQXTE/s3SZeghzo8sxZm/vswPnUsqUAysVbbmhIeFS/95Lj8LmFZMoZ0lsIJT9m9/mt2/BxfOEEpP/a+YklOm5IWaFcxgAdup9ygWEkahq0nhDEzcfkzWLfjR3D424H7nHkO3SomNMD7qRFEv1WLV1KlHpTrqXC07J15tVHLl4xvXLwxCNPNh7PPwwYobe9A/d3x7hkNtM1n+QeiEBCfwW9kRBUpT68dry/mJeF8zkZpM7wUS3q0nxmZUcJfanf2inek+GEaT0rw0/20Agy69HadanfL1N0ToTmM+RR0vMOCFQkzUEFa9BVwQmEr2/zs1pAsLFG6gAOFe1ckJvrZTK3K6gGBrkVj9Kq7JH8zc95yZbrIn8YKWlIZyr8MXCXF8QybBA3F2z4CvahxqE+Mb7x14XptIuKFohiKuZezlBlYIPy8bvxvLRn4yyDsqC0BD1FTuVY0zEyFkxyqq7v4RRJsoiOiKo664c4HU7eY4pcH0dER+i4sk8f6VQ2IJDfGo+Ai33wjokgaFuyLL/llUF4t3CGw1OZ2+1aa0iOkB/nrqSbFagmIlMrp9DfW1PwnRQRU1osaj6cT/AgvBUGZRiLtgAAAAAElFTkSuQmCC);
            }            
         }
      }
      
   }
   
   
   .content{
      width : 100%;
      height:0;
      position : relative;
      padding-bottom : 56.25%;
      
      iframe{
         display:block;
         position: absolute;
         width:100%;
         height:100%;
      }
   }
}

            
          
!
            
              var Browser = function(elem){
   var that = this;
   
   that.elem = elem;
   that.url = that.elem.getAttribute("data-url") || 'http://example.com/';
   
   that.timer;
   
   that.address_bar;
   that.iframe;
   
   // the entire logic
   that.createBrowser().loadUrl();
}

Browser.prototype.createBrowser = function(){
   var that = this;
   
   var ctrls, ctrlBtn, previous, next, bar, address, reload, content, thewebsite;
   
//    empty the original
   while(that.elem.firstChild){
      that.elem.removeChild(that.elem.firstChild);
   }
   
//    The ctrls
   ctrls = document.createElement("div");
   ctrls.className += " ctrls";
   
   ctrlBtn = document.createElement("div");
   ctrlBtn.className += " ctrl-btn";
   ctrls.appendChild(ctrlBtn);
   
   previous = document.createElement("div");
   next = document.createElement("div");
   previous.className += " previous";
   next.className += " next";
   ctrlBtn.appendChild(previous);
   ctrlBtn.appendChild(next);
   
   
   bar = document.createElement("div");
   bar.className += " bar";
   ctrls.appendChild(bar);
   
   address = document.createElement("input");
   address.className += " address";
   address.value = that.url;
   
   address.onkeyup = function(e){
      clearTimeout(that.timer);
      if(e.which == 13){
         that.url = address.value;
         that.loadUrl();
      }
      else{
         that.timer = setTimeout(function(){
            that.url = address.value;
            that.loadUrl();
         }, 3000);
      }
   };
   
   that.address_bar = address;
   bar.appendChild(address);
   
   reload = document.createElement("div");
   reload.className += " reload";
   reload.addEventListener("click", function(){
      that.loadUrl();
   })
   bar.appendChild(reload);
   
//    content
   content = document.createElement("div");
   content.className += " content";
   
   thewebsite = document.createElement("iframe");
   thewebsite.className += " thewebsite";
   thewebsite.setAttribute('frameborder', 0);
//    thewebsite.src = that.url; // chaining at the beginning;
   that.iframe = thewebsite;
   content.appendChild(thewebsite);
   
   that.elem.appendChild(ctrls);
   that.elem.appendChild(content);
   
   return that;
}


Browser.prototype.loadUrl = function(){
   var that = this;
   that.iframe.src = that.address_bar.value;
}




// onload, reference all browsers and make them work! :)
window.onload = function(){
   var browsers = document.getElementsByClassName("z-browser");
   for(var i=0; i < browsers.length; i++){
      var browser = browsers[i];
      new Browser(browser);
   }
}

            
          
!
999px
Loading ..................

Console