liabru/jquery-match-height được TopGit xếp vào nhóm dự án frontend, với 3.0k sao trên GitHub, viết chủ yếu bằng JavaScript. a responsive equal heights plugin
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
matchHeight makes the height of all selected elements exactly equal
brm.io/jquery-match-height
Demo - Features - Gallery - Install - Usage - Options - Data API
Advanced Usage - Tests - Known limitations - Changelog - License
Demo
See the jquery.matchHeight.js demo.
Modern browsers
In the years since this library was originally developed there have been updates to CSS that can now achieve equal heights in many situations. If you only need to support modern browsers then consider using CSS Flexbox and CSS Grid instead.
Features
match the heights for groups of elements automatically
use the maximum height or define a specific target element
anywhere on the page and anywhere in the DOM
responsive (updates on window resize)
row aware (handles floating elements and wrapping)
accounts for box-sizing and mixed padding, margin, border values
handles images and other media (updates after loading)
supports hidden or none-visible elements (e.g. those inside tab controls)
throttled to balance performance and smoothness
easily removed when needed
maintain scroll position
data attributes API
callback events
unit tests
module loader support
tested in IE8+, Chrome, Firefox, Safari, Android, iOS
Gallery
See how others are using jquery.matchHeight.js
Visa
Nokia
PayPal
MTV
Bose
Chipotle
Fisher-Price
Sega
barackobama.com
more...
Install
jQuery is required, so include it first.
Download jquery.matchHeight.js and include the script in your HTML file:
Where options is an optional parameter.
See below for a description of the available options and defaults.
The above example will set all selected elements with the class item to the height of the tallest.
If the items are on multiple rows, the items of each row will be set to the tallest of that row (see byRow option).
Call this on the DOM ready event (the plugin will automatically update on window load).
See the included test.html for many working examples.
Also see the Data API below for a simple, alternative inline usage.
property is the CSS property name to set (e.g. 'height' or 'min-height')
target is an optional element to use instead of the element with maximum height
remove is true or false to remove previous bindings instead of applying new ones
Data API
Use the data attribute data-mh="group-name" where group-name is an arbitrary string to identify which elements should be considered as a group.
<div data-mh="my-group">My text</div>
<div data-mh="my-group">Some other text</div>
<div data-mh="my-other-group">Even more text</div>
<div data-mh="my-other-group">The last bit of text</div>
All elements with the same group name will be set to the same height when the page is loaded, regardless of their position in the DOM, without any extra code required.
Note that byRow will be enabled when using the data API, if you don't want this (or require other options) then use the alternative method above.
Advanced Usage
There are some additional functions and properties you should know about:
Manually trigger an update
$.fn.matchHeight._update()
If you need to manually trigger an update of all currently set groups, for example if you've modified some content.
Row detection
You can toggle row detection by setting the byRow option, which defaults to true.
It's also possible to use the row detection function at any time:
$.fn.matchHeight._rows($('.item'));
Which will return an array of element selections for each row, see this thread for more information and an example.
Remove bindings
$('.item').matchHeight({ remove: true });
This will remove all bindings for the selected elements, from all groups.
This will set the min-height property instead of the height property.
Callback events
Since matchHeight automatically handles updating the layout after certain window events, you can supply functions as global callbacks if you need to be notified:
$.fn.matchHeight._beforeUpdate = function(event, groups) {
// do something before any updates are applied
}
$.fn.matchHeight._afterUpdate = function(event, groups) {
// do something after all updates are applied
}
Where event a jQuery event object (e.g. load, resize, orientationchange) and groups is a reference to $.fn.matchHeight._groups (see below).
Manually apply match height
$.fn.matchHeight._apply(elements, options)
Use the apply function directly if you wish to avoid the automatic update functionality.
Throttling resize updates
$.fn.matchHeight._throttle = 80;
By default, the _update method is throttled to execute at a maximum rate of once every 80ms.
Decreasing the above _throttle property will update your layout quicker, appearing smoother during resize, at the expense of performance.
If you experience lagging or freezing during resize, you should increase the _throttle property.
Maintain scroll position
$.fn.matchHeight._maintainScroll = true;
Under certain conditions where the size of the page is dynamically changing, such as during resize or when adding new elements, browser bugs cause the page scroll position to change unexpectedly.
If you are observing this behaviour, use the above line to automatically attempt to force scroll position to be maintained (approximately). This is a global setting and by default it is false.
Accessing current group bindings
$.fn.matchHeight._groups
The array that contains all element groups that have had matchHeight applied. Used internally for automatically updating on resize events, but you may modify this array if you need to manually access any groups (e.g. if you're deleting elements).
Tests
Open test/page/test.html in your browser to run unit tests via the jasmine test runner.
If you wish to contribute functionality to this project, you are encouraged to add new tests following the same conventions.
Run gulp test to run unit tests on multiple browsers and multiple resolutions, automatically through selenium.
Run gulp test:cloud to test on even more browsers via a cloud service (you will need to create a file called test/conf/private.conf.js with your cloud credentials that looks like this:
Cloud browser testing for this project is provided by BrowserStack (which is free for open source).
Known limitations
CSS transitions and animations are not supported
You should ensure that there are no transitions or other animations that will delay the height changes of the elements you are matching, including any transition: all rules. Otherwise the plugin will produce unexpected results, as animations can't be accounted for.
Delayed webfonts may cause incorrect height
Some browsers do not wait for webfonts to load before firing the window load event, so if the font loads too slowly the plugin may produce unexpected results.
If this is a problem, you should call _update once your font has loaded by using something like the webfontloader script.
Content changes require a manual update
If you change the content inside an element that has had matchHeight applied, then you must manually call $.fn.matchHeight._update() afterwards. This will update of all currently set equal heights groups.
Also note that previous matchHeight bindings do not apply to new elements, even if they match the selector used. In this case you must remove the old bindings and add new ones, see this comment.
Changelog
To see what's new or changed in the latest version, see the changelog
License
jquery.matchHeight.js is licensed under The MIT License (MIT)
Copyright (c) 2014 Liam Brummitt
This license is also supplied with the release and source code.
As stated in the license, absolutely no warranty is provided.
liabru/jquery-match-height thuộc nhóm Frontend trên TopGit, cùng 5 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về liabru/jquery-match-height ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/liabru/jquery-match-height là nguồn chính thức.
liabru/jquery-match-height có bao nhiêu sao?
liabru/jquery-match-height có 3.0k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/liabru/jquery-match-height. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
liabru/jquery-match-height có phải mã nguồn mở không?
Có — liabru/jquery-match-height phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/liabru/jquery-match-height.
liabru/jquery-match-height có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho liabru/jquery-match-height. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
liabru/jquery-match-height là gì?
liabru/jquery-match-height (liabru/jquery-match-height) là dự án JavaScript trên GitHub. Theo mô tả gốc: a responsive equal heights plugin
liabru/jquery-match-height so với các dự án Frontend khác thế nào?
liabru/jquery-match-height được TopGit xếp vào nhóm Frontend, với 3.0k sao GitHub và viết bằng JavaScript. Xem trang chủ đề Frontend trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc đầy đủ README ở tab phía trên.
jquery-match-height có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về jquery-match-height.