2014-01-17 33 views
4

當我打開模式窗口時,它會一直滾動背景上下文到頂部。示例我在打開模式窗口的頁面底部有鏈接。當我點擊鏈接時,窗口將滾動到文檔的頂部,然後顯示模式窗口。我對模態窗口的定位沒有問題。我只是不希望在打開頁面之前發生捲動。我主要使用來自BS v3(​​github上的最新版本)和默認模態主體的默認CSS。我使用JS來填充模態的標籤和身體,然後打開它Bootstrap v3 - 打開模式窗口強制頁面滾動到頂部

<!-- Modal --> 
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-dialog"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
     <h4 class="modal-title" id="myModalLabel">Modal title</h4> 
     </div> 
     <div class="modal-body" id="myModalBody"></div> 
    </div><!-- /.modal-content --> 
    </div><!-- /.modal-dialog --> 
</div><!-- /.modal --> 
+1

由於例如在'getboostrap.com'網站工作正常,它必須是在您的代碼中的東西。如果你可以張貼小提琴,我們可以幫你解決,但否則你會得到的只是猜測。 –

+0

感謝您的回覆。 TY是正確的..這是一個問題

回答

0

這可能是你的模態代碼的HTML樹中的位置,嘗試向上或向下移動它的水平。

+2

How are you opening the window? via an anchor tag or button? If you're doing it with an anchor tag is the 'href' value '#'? –

+0

Ty. I am. I'm doing something like this More Info然後當他們點擊它..運行.ajax調用來拉取一些數據..填充我的模態..然後只需調用$('#modal')。modal('show 「);在完成 –

+2

謝謝!關於

相關問題