Dave Cardwell (jQuery plugins)
jQMinMax is a jQuery plugin that adds support for min-width
, max-width
, min-height
and max-height
where they are not natively supported. This page describes version 0.1.
jQMinMax automatically adds min/max support to those elements that require it on $(document).ready()
.
$('#foo').minmax();
This method checks to see whether the elements’ width and height have fallen outside the min/max constraints and updates them appropriately. It returns an array of jQuery objects.
$.minmax.expressions();
This method is called as part of the automatic processes for browsers that don’t support minmax natively, and as such shouldn’t need to be used again. I have given it a Public interface, however, in case you want to use the selectors listed below in browsers that already support the minmax CSS properties themselves.
$(':min-width')
, $(':max-width')
, $(':min-height')
, $(':max-height')
, and $(':minmax')
These selectors find all elements with the given style property set. $(':minmax')
is added for convenience, and selects all elements with any min/max style.
jQMinMax has only been tested with a recent release of jQuery from SVN. If you encounter any problems, upgrading your jQuery library could be your first port of call. The first version of jQuery to be officially supported will be the upcoming release of version 1.0.
If jQMinMax detects that your browser supports minmax natively ($.minmax.native
) it will not take any further action.
jQMinMax is released under the MIT License. Attribution and links are always well received. If you do find a use for this plugin, I’d love to hear about the project.
You can download jQMinMax v0.1 uncompressed (5.7K) or compressed (1.9K) with Dean Edwards’ packer.
No support detection attempted.
The following boxes should all appear as 100x100px squares.
min-width
max-width
min-width
and max-width
min-height
max-height
min-width
and padding
max-width
with percentage valuesjQMinMax v0.1 has no known bugs.