2012-09-11 78 views
0

我用一些JavaScript,其滑动从网页底部的DIV了,我一直在努力,绝对底部中心位置的。绝对定位不工作的Javascript DIV

底部的DIV似乎是左下角,我已经试过有它为中心,不管浏览器窗口大小是什么。

我想看看这个网址,看到有问题的网页:http://s361608839.websitehome.co.uk/oneonly/index.html

HTML:

<div class="slide-out-div"> 
    <a class="handle" href="http://link-for-non-js-users">Content</a> 
    <a href="mailto:[email protected]">[email protected]</a><br /><br /> 
    <p>Address</p> 
    <p>Telephone</p> 
</div> 

CSS:

.slide-out-div { 
    padding: 20px; 
    width: 276px; 
    background: url(images/kontakt-bg.png); 
    color: #fff; 
} 

JS:

$(function(){ 
    $('.slide-out-div').tabSlideOut({ 
    tabHandle: '.handle',      //class of the element that will be your tab 
    pathToTabImage: 'images/kontakt-tab.png', //path to the image for the tab (optionaly can be set using css) 
    imageHeight: '26px',       //height of tab image 
    imageWidth: '316px',       //width of tab image  
    tabLocation: 'bottom',      //side of screen where tab lives, top, right, bottom, or left 
    speed: 300,         //speed of animation 
    action: 'click',        //options: 'click' or 'hover', action to trigger animation 

    fixedPosition: false       //options: true makes it stick(fixed position) on scroll 
    }); 
}); 

谢谢!

+0

我希望这有助于http://stackoverflow.com/questions/210717/using-jquery-to-center-a-div-在屏幕上 –

回答

0

添加

left: 50%; 
margin-left: -138px; /* half its width which you have set to be 276px */ 

.slide-out-div(通过开发工具进行编辑时,现场工作对我来说)。

+0

完美,非常感谢:) – Tim

0

你有一个左侧位置添加到.slide-out-div

<div class="slide-out-div" 
    style="line-height: 1; position: fixed; bottom: -124px; width: 300px; left: 50%; margin-left: -150px; "> 

凡切缘阴性是宽度的一半。

0

添加到您的.slide出-DIV级

margin-left: -138px; /* half of the width of the div */ 
left: 50%;