Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit aaaba5b

Browse files
committed
[Task] initial import
1 parent ade841f commit aaaba5b

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ equal-height
22
============
33

44
(jQuery Plugin, Bower)
5+
6+
jQuery Plugin for getting and setting the min-height of given elements to the highest calculated value.

mf_EqualHeight.jquery.plugin.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**********************************************************
2+
3+
@description sets css min-height of given elements to the highest calculated value
4+
***********************************************************/
5+
6+
;(function($) {
7+
8+
$.fn.mf_EqualHeight = function() {
9+
10+
var heights = 0;
11+
12+
this.each(function() {
13+
14+
// cache object height
15+
var obj_height = $(this).height();
16+
17+
// save it if it is higher than before
18+
if(heights < obj_height) {
19+
heights = obj_height;
20+
}
21+
});
22+
23+
// set height of given elements to calculated value
24+
this.css('min-height', heights);
25+
26+
// preserve chainability
27+
return this;
28+
};
29+
30+
})(jQuery);

test.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8">
4+
<title>test</title>
5+
<style>
6+
div {
7+
float: left;
8+
padding: 20px;
9+
background: #ccc;
10+
width: 10%;
11+
margin: 10px;
12+
}
13+
</style>
14+
</head>
15+
<body>
16+
<div>test</div>
17+
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto veritatis reiciendis repellendus autem aspernatur asperiores nihil unde? Laborum cumque inventore nemo eum ab debitis adipisci a obcaecati nesciunt commodi doloribus.</div>
18+
<div>test2</div>
19+
</body>
20+
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
21+
<script src="mf_EqualHeight.jquery.plugin.js"></script>
22+
<script>
23+
$('div').mf_EqualHeight();
24+
</script>
25+
</html>

0 commit comments

Comments
 (0)