2015-09-21 64 views
0

這是我的HTML代碼,下面是jQuery代碼。jQuery模態高度響應

<div class="popup-overlay"> 
<div class="popup " id="first"> 
    <div id="style-1" class="scrollbar"> 
    <div class="wdth123"> 
<!-- some content here almost width of 500px height of 800px; --> 
    </div> 
    </div> 
    </div> 
</div> 

這裏是我的jQuery代碼

<script src="jQmodals.min.js"></script> 

<script type="text/javascript"> 

    $(function() { 
    var modal = $('.popup-overlay').jQmodals(); 
    $('.open').on('mousedown', modal.open.bind(modal, '#first')); 
    $(document).on('mousedown', '.popup .close-btn', modal.close.bind(modal)); 

}); 

    $(function() { 
    var modal = $('.popup-overlay1').jQmodals(); 
    $('.opens').on('mousedown', modal.open.bind(modal, '#firsts')); 
    $(document).on('mousedown', '.popups .close-btns', modal.close.bind(modal)); 

}); 

我的所有彈出工作正常,只是我想高度響應的所有設備上的寬度,但在高度它不工作,請幫助我的工作的罰款。 。

回答

2

$(document).ready(function(){ 
 
    var height = $(window).height(); 
 
    $(".popout").height(height); 
 
    $(window).scroll(function(){ 
 
    height = $(window).height(); 
 
    $(".popout").height(height); 
 
    }); 
 
    
 

 
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

0

你必須使用視窗大中印刷術的高度

.popup {height:1vw 
} 

VW:1 /第100次的視口寬度 VH:1 /第100次視口高度 VMIN:1 /第100次的最小側 的VMAX:1 /第100次最大側

0

使用的jquery .height()函數的。 http://api.jquery.com/height/

$(document).ready(function(){ 
 
    $(".popout").height($(window).height()); 
 
    $(window).resize(function(){ 
 
    $(".popout").height($(window).height()); 
 
    }); 
 
});