Skip to content

Commit 75a6c48

Browse files
committed
Fixed markdown
1 parent 9002338 commit 75a6c48

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
jQuery Flex Vertical Center
2+
===========================
3+
4+
This jQuery plugin provides an easy way to vertically center an element in its parent. Even if the parents height changes after resizing the browser window, in a fluid or responsive layout for example.
5+
6+
7+
Usage
8+
-----
9+
10+
Simply include this file in your project (after loading jQuery) like this:
11+
12+
<script defer src="js/jquery.flexverticalcenter.js"></script>
13+
14+
Then call the plugin on the element which needs to be vertically centered in it's parent.
15+
16+
<script>
17+
$(document).ready(function() {
18+
$('#element-to-be-centered').flexVerticalCenter();
19+
});
20+
</script>
21+
22+
This will take the parents height, the elements own height and calculate the distance the element should have from the parents top to be vertically centered. This value is applied to the top margin of the element by default.
23+
24+
25+
Options
26+
-------
27+
28+
You can pass one parameter to the plugin, which is the css attribute that the value should be set on. The default is 'margin-top', but you can pass any attribute you would like. Most probably 'padding-top' or 'top'.
29+
30+
<script>
31+
$(document).ready(function() {
32+
$('#element-to-be-centered').flexVerticalCenter('padding-top');
33+
});
34+
</script>
35+
36+
37+
Note
38+
----
39+
40+
The initial code was more or less borrowed from the awesome FitText plugin. http://fittextjs.com/

0 commit comments

Comments
 (0)