2014-07-23 3 views
0

으로 바꾸십시오. 현재 jQuery spin.js 회 전자에는 배치 할 수있는 옵션이 있습니다.대상 div에 대한 spin.js 회 전자의 위치를 ​​

내가 전에 다음 설정을 사용하고 있습니다 :

 // set up spin.js vars 
    var opts = { 
     lines: 13, // The number of lines to draw 
     length: 5, // The length of each line 
     width: 2, // The line thickness 
     radius:5, // The radius of the inner circle 
     corners: 1, // Corner roundness (0..1) 
     rotate: 58, // The rotation offset 
     direction: 1, // 1: clockwise, -1: counterclockwise 
     color: '#fff', // #rgb or #rrggbb or array of colors 
     speed: 0.9, // Rounds per second 
     trail: 100, // Afterglow percentage 
     shadow: false, // Whether to render a shadow 
     hwaccel: false, // Whether to use hardware acceleration 
     className: 'mySpinner', // The CSS class to assign to the spinner 
     zIndex: 2e9, // The z-index (defaults to 2000000000) 
     top: '50%', // Top position relative to parent 
     left: '50%' // Left position relative to parent 
    }; 

    // show a spinner in place of the icon 
    var target = document.getElementById('testdiv'); 
    var spinner = new Spinner(opts).spin(target); 
    $(target).data('mySpinner', spinner); 

위치가 부모에 상대적를 보여줍니다 그러나

.

는 따라서 현재의 구조 :

<div id="container"> 
    <div id="testdiv"> 
    </div> 
<div> 

은 스피너는 포함 DIV 아니라 타겟팅 된 사업부를 중심으로 얻을 것이다. 이 문제를 해결할 방법이 있습니까? 당신은 여전히 ​​해결책을 찾고 있다면

답변

0

, 난 당신과 같이 작동하도록 position: relative을 사용할 수있는 것 같아요 :

.mySpinner { 
    position: relative !important; 
} 

이 방법 스피너는 testdiv의 중심 될 것입니다. Here's a working JsFiddle.

관련 문제