-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
259 lines (228 loc) · 13 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../assets/ico/favicon.png">
<title>responsiveElement.js</title>
<!-- Bootstrap -->
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/docs.css" rel="stylesheet">
<link href="assets/css/styles.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="">
<header class="navbar navbar-fixed-top navbar-inverse" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#js">responsiveElement.js</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#download">Download</a></li>
<li class="active">
<a href="#installation">Installation</a>
<ul class="dropdown-menu" role="menu">
<li><a href="#step1" tabindex="-1">Link Required Files</a></li>
<li><a href="#step2" tabindex="-1">Create HTML Markup</a></li>
<li><a href="#step3" tabindex="-1">Call responsiveElement</a></li>
</ul>
</li>
<li>
<a href="#config">Configuration</a>
<ul class="dropdown-menu" role="menu">
<li><a href="#rules">Rules</a></li>
</ul>
</li>
<li><a href="#examples">Working Examples</a></li>
<li><a href="https://github.com/brandonferens/responsive-elements" class="visible-xs"><i class="icon-github"></i> Fork on Github</a></li>
</ul>
</div><!-- /.nav-collapse -->
</div><!-- /.container -->
<a href="https://github.com/brandonferens/responsive-elements" class="hidden-xs"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
</header><!-- /.navbar -->
<div class="container">
<div class="row">
<div class="col-12 col-sm-12">
<div class="row">
<div class="col-3 col-xs-3 hidden-xs hidden-sm" id="sidebar" role="navigation">
<div class="bs-sidebar affix" role="complementary">
<ul class="nav bs-sidenav">
<li><a href="#js">responsiveElement.js</a></li>
<li><a href="#download">Download</a></li>
<li class="active">
<a href="#installation">Installation</a>
<ul class="nav">
<li><a href="#step1">Link Required Files</a></li>
<li><a href="#step2">Create HTML Markup</a></li>
<li><a href="#step3">Call responsiveElement</a></li>
</ul>
</li>
<li>
<a href="#config">Configuration</a>
<ul class="nav">
<li><a href="#rules">Rules</a></li>
</ul>
</li>
<li><a href="#examples">Working Examples</a></li>
<li><a href="#license">License</a></li>
</ul>
</div><!--/.well -->
</div><!--/span-->
<div class="col-9 col-md-9">
<section>
<h1 id="js">responsiveElement.js</h1>
<hr />
<p>Element queries don't exist yet for CSS3, but this plugin allows you to do just that with jQuery.</p>
<p>This plugin changes the class of an element depending on its width. By changing the class like this, you can now use CSS to manipulate and alter the contents of the element essential creating functionality similar to a media query. Only instead of being window width dependent, it is dependent upon it's own width. Enjoy!</p>
<p>And weighing in at only <strong>670 bytes</strong>, it is has a lot of punch for its size while keeping your bandwidth at a minimum!</p>
</section>
<section>
<h1 id="download">Download</h1>
<hr />
<p>You have a couple choices in front of you:</p>
<ul class="list-unstyled">
<li>
<i class="icon-download"></i>
<strong>Download package:</strong>
<a href="https://github.com/brandonferens/responsive-elements/archive/master.zip">responsiveElement.zip</a>
</li>
<li>
<i class="icon-github"></i>
<strong>Fork on Github:</strong>
<a href="https://github.com/brandonferens/responsive-elements">Fork here</a>
</li>
</ul>
</section>
<section>
<h1 id="installation">Installation</h1>
<hr />
<h3 id="step1">Step 1: Link Required Files</h3>
<p>The jQuery library needs to be loaded first, then this plugin.</p>
<pre class="pre-scrollable"><code class="html"><span class="nt"><script</span><span class="na"> src=</span><span class="s">"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"</span><span class="nt">></script></span>
<span class="nt"><script</span><span class="na"> src=</span><span class="s">"/js/jquery.responsiveElement.min.js"</span><span class="nt">></script></span></code></pre>
<h3 id="step2">Step 2: Create HTML Markup</h3>
<p>Locate the element you want made responsive and add add any class name you want to it. For this example, we will make it "responsive".</p>
<div class="highlight">
<pre><code class="html"><span class="nt"><div</span><span class="na"> class=</span><span class="s">"responsive"</span><span class="nt">></span>
<span> The content of my div is here</span>
<span class="nt"></div></span></code></pre>
</div>
<h3 id="step3">Step 3: Call responsiveElement</h3>
<div class="highlight">
<pre><code class="js"><span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">() {</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">'.responsive'</span><span class="p">).</span><span class="nx">responsiveElement</span><span class="p">();</span>
<span class="p">});</span></code></pre>
</div>
<p>That's it!</p>
<p>There are a couple options that can be applied to customize it. You can also apply this to multiple elements on the page at a time, all with different options!</p>
</section>
<section>
<h1 id="config">Configuration Options</h1>
<hr>
<h4 id="rules">rules</h4>
<p>Rules that are applied to the element in question. The default widths are based off of Twitter Bootstrap 8 column widths.</p>
<div class="highlight">
<pre><code class="js"><span class="nx">default</span><span class="o">:</span><span class="p"> [</span>
<span class="s1">'750,responsive-lg'<span class="p">,</span></span>
<span class="s1">'617,responsive-md'<span class="p">,</span></span>
<span class="s1">'470,responsive-sm'<span class="p">,</span></span>
<span class="s1">'0,responsive-xs'</span>
<span class="p">]</span></code></pre>
</div>
<p>The format of the each element in the default array is "minimum pixel width, class to be applied". So if the width of <code><div class="responsive"></code> is 750 pixels or larger, then the element will become <code><div class="responsive responsive-lg"></code>.</p>
<p>See the example below for a usage example.</p>
<div class="highlight">
<pre><code class="js"><span class="nx">$</span><span class="p">(</span><span class="s1">'.customRules'</span><span class="p">).</span><span class="nx">responsiveElement</span><span class="p">({</span>
<span class="nx">rules</span><span class="o">:</span><span class="p"> [</span>
<span class="s1">'600,customRulesLarge'<span class="p">,</span></span>
<span class="s1">'400,customRulesMedium'<span class="p">,</span></span>
<span class="s1">'200,customRulesSmall'<span class="p">,</span></span>
<span class="s1">'0,customRulesXSmall'</span>
<span class="p">]</span>
<span class="p">});</span></code></pre>
</div>
<p><label class="label label-info">Remember</label> When the width of an element is determined by either css or javascript, things like border widths and padding are included. Because of this, it is easiest to place your element in a wrapper and apply responsiveElement to that instead.</p>
</section>
<section>
<h1 id="examples">Working Examples</h1>
<hr>
<p>Go ahead! Give it a try! Resize your browser to see responsiveElement.js in action!</p>
<div class="responsive">
<div>
<h4>Default Ruleset</h4>
<p>This box's background color will change based on the width of the element. It uses the default ruleset of responsiveElement.js.</p>
</div>
</div>
<div class="customRules">
<div>
<h4>Custom Ruleset</h4>
<p>This box's background color will also change based on the width of the element. However, it uses a custom ruleset. View the source of this page to see what is going on.</p>
<p>It's background color will change based on the following widths:
<ul>
<li>Greater than or equal to 600px</li>
<li>Greater than or equal to 400px</li>
<li>Greater than or equal to 200px</li>
<li>Greater than or equal to 0px</li>
</ul>
</p>
</div>
</div>
</section>
<section>
<h1 id="license">License</h1>
<hr />
<p>responsiveElement.js is open-sourced software licensed under the [MIT license] (http://opensource.org/licenses/MIT)</p>
</section>
</div>
</div>
</div>
</div><!--/row-->
<footer class="bs-footer">
<div class="container">
<div class="bs-social">
<ul class="bs-social-buttons">
<li>
<iframe src="http://ghbtns.com/github-btn.html?user=brandonferens&repo=responsive-elements&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="95" height="20"></iframe>
</li>
<li>
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://responsiveElement.brandonferens.com" data-via="bferens">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</li>
</ul>
</div>
</div>
<p>responsiveElement.js made with love by <a href="https://twitter.com/bferens">Brandon Ferens</a>, aka <a href="https://twitter.com/bferens">@bferens</a>
</footer>
</div><!--/.container-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.responsiveElement.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script type="text/javascript">
// The basic function with no additional parameters
$('.responsive').responsiveElement();
// The function with widths and class names supplied
$('.customRules').responsiveElement({
rules: [
'0,customRulesXSmall',
'200,customRulesSmall',
'400,customRulesMedium',
'600,customRulesLarge',
]
});
</script>
</body>
</html>