Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
#center-box{
 position:absolute;
 width:300px;
 height:100px;
 background:#C0C0C0;
 border:1px solid #000;
 }
</style>
</head>
<body>
  <div id="center-box">
  fvfgfgfg  
  </div>
</body>
</html>
 
$(document).ready(function(){
  var windowheight = $(window).height();
  var windowwidth = $(window).width();
  var pagecenterW = windowwidth/2;
  pagecenterW=pagecenterW/2;
  var pagecenterH = windowheight/2;
  pagecenterH=pagecenterH/2;
  $("div#center-box")
      .css({top: pagecenterH + 'px', left: pagecenterW+ 'px'});
});
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers