2013-04-02 4 views
7

में परिभाषित करता है मैंने एक छोटी परियोजना बनाई है जिसमें मुझे एक मॉडल संवाद प्रदर्शित करना है जिसके लिए मैंने jquery-ui संवाद का उपयोग किया है।jquery संवाद maxheight को

मैं प्रतिशत में संवाद के लिए अधिकतम ऊंचाई को परिभाषित करना चाहता हूं। मैंने कई चीजों की कोशिश की है लेकिन उनमें से कोई भी काम नहीं कर रहा है।

कृपया कोई मेरी मदद कर सकता है कि समस्या क्या हो सकती है।

http://jsbin.com/otiley/1/edit

बहुत धन्यवाद

उत्तर

13

प्रतिशत में ऊंचाई सेट करने के लिए this लिंक आज़माएं।

$(document).ready(function() { 
$('#testColorBox').click(function() { 
    var wWidth = $(window).width(); 
    var dWidth = wWidth * 0.8; 
    var wHeight = $(window).height(); 
    var dHeight = wHeight * 0.8; 
    var $link = $(this); 
    var $dialog = $('<div></div>') 
     .load('test.html') 
     .dialog({ 
      autoOpen: false, 
      modal: true, 
      title: $link.attr('title'), 
      overlay: { opacity: 0.1, background: "black" }, 
      width: dWidth, 
      height: dHeight, 
      draggable: false, 
          resizable: false 
     }); 
    $dialog.dialog('open'); 
    return false; 
    }); 
}); 
+3

इस का एक लघु संस्करण है: '$ (" # चयनकर्ता ") संवाद ({चौड़ाई:। $ (विंडो) .width() * 0.8, ऊंचाई: $ (विंडो) .height() * 0.8 }); ' – degenerate

6

देखें jQuery यूआई केवल आप पिक्सल में अधिकतम ऊंचाई व्यक्त करने के लिए अनुमति देता है। आपको अपने कोड में प्रतिशत के लिए गणना करने की आवश्यकता होगी।

$(document).ready(function(){ 
    $("#dialog-modal").html($("#temp").html()); 
    $("div#dialog-modal").dialog({ 
     height: "auto", 
    maxHeight: $("div#dialog-modal").outerHeight() * .2, 
     resizable: false, 
     width: "70%", 
     modal: true, 
     title: "Hello" 
    }); 
}); 
2

आप खिड़की की ऊंचाई या कुछ div की ऊंचाई की जांच करके ऐसा कर सकते हैं। http://jsbin.com/otiley/4/edit

या::

$(document).ready(function(){ 
    var height = $(window).height(); 
    height = height*0.20; 
    $("#dialog-modal").html($("#temp").html()); 
    $("div#dialog-modal").dialog({ 
     height: "auto", 
     maxHeight: height, 
     resizable: false, 
     width: "70%", 
     modal: true, 
     title: "Hello" 
    }); 
}); 

आप किसी भी div की ऊंचाई लेने के लिए और किसी भी वांछित प्रतिशत की गणना कर सकते

यहाँ एक उदाहरण है।

संबंधित मुद्दे