Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting min-width - jQuery

Tags:

jquery

resize

This works great:

$(document).ready(function() {
    var previewwidth = ($(window).width() - ( $('.aside').width() + $('.results').width() + 110) ) ;
    $(".result-preview").width(previewwidth);
    $("footer").text(previewwidth);

});


$(window).resize(function() {
    var previewwidth = ($(window).width() - ( $('.aside').width() + $('.results').width() + 110) ) ;
    $(".result-preview").width(previewwidth);
    $("footer").text(previewwidth);
});

but I'm not sure how to set min and max width, so min-width to 338px and max-width to 500px.

thanks!

like image 415
eozzy Avatar asked Mar 20 '12 16:03

eozzy


People also ask

How to set min width in jQuery?

Dialog minWidth option is used to set the minimum width that can be set to the dialog box in pixels. By default, the value is 150.

How can set width percentage in jQuery?

width("20%") however the element kept getting set to width: 24% . After digging through the docs, turns out this is related to the CSS box-sizing property. Using . css({'width':"20%"}) will avoid this adjustment.

What does innerWidth () method do in jQuery?

The innerWidth() method returns the inner width of the FIRST matched element.


1 Answers

 $(".result-preview").css({
     "min-width": "338px", 
     "max-width": "500px"
 });
like image 131
Engineer Avatar answered Sep 21 '22 12:09

Engineer