Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
var oldBodyOuterWidth = body.outerWidth(true);
var oldScrollTop = html.scrollTop();
html.css('overflow-y', 'hidden');
newBodyOuterWidth = body.outerWidth(true);
body.css('margin-right', (newBodyOuterWidth - oldBodyOuterWidth) + 'px');
html.scrollTop(oldScrollTop); // necessary for Firefox
.arcticmodal-overlay~.arcticmodal-overlay {
background-color: transparent!important;
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tree Example</title>
<style>
*{
margin:0;
}
#test{
width:100px;
height:100px;
background-color:red;
margin:0 auto;
position:fixed;
left:0;
right:0;
}
</style>
</head>
<body>
<div id="test">Test</div>
<script>
var
test=document.getElementById('test');
test.style.top=(document.body.clientHeight/2-test.getBoundingClientRect().height/2)+'px';
</script>
</body>
</html>
arcticModal — jQuery-плагин для модальных окон