Responsify.js
92 | 93 |A jquery plugin that makes images truly responsive, without sacrificing anyone's face :D
When images are used in a responsive container on web design, because of the container can change to any width:height ratio, a group shot could end up being cut off on people's faces, a nice photograph following "rule of third" could end up with no object in view. Responsive images face the challenge of how to keep the focused objects/area in view, this jquery plugin is here to solve the problem.
96 | 97 |Download
98 | 99 |-
100 |
- responsify.js 101 |
- responsify.min.js 102 |
Demo
105 | 106 |http://responsifyjs.space/#demo
107 | 108 |App
109 | 110 | 111 | 112 |Use this interactive web app to generate the focus area data
113 | 114 |What it does
115 | 116 |Responsify.js does the following:
117 | 118 |-
119 |
- It allows you define a focus area on an image using
data-focus-xxx
tag
120 | - It takes in the focus area data from the image, calcuate the image's container's size, resize and position the image accordingly, make sure the focus area is always in view and in the best position possible. 121 |
Responsive image with responsify.js
124 | 125 |-
126 |
- view gif | play it yourself 127 |
Responsive image without responsify.js
130 | 131 |-
132 |
- view gif | play it yourself 133 |
How to use
136 | 137 |-
138 |
Use this interactive web app to generate the focus area data http://responsifyjs.space/app/
139 | 140 |
143 | 144 |<img src="image.png" alt="" 141 | data-focus-left=".30" data-focus-top=".12" data-focus-right=".79" data-focus-bottom=".66" /> 142 |
data-focus-left
is the focus area's left position comparing to the image's full width, in decimal. For example, if the full width is 300px, the focus area's left is 90, then thedata-focus-left
should be 90/300 =0.3
. Same logic applies to other three data attributes.
145 | Embed the responsify.js in the html
146 | 147 |<script src="responsify.js"></script> 148 |
149 | Call responsify function when window object is loaded
150 | 151 |$(window).load(function() { 152 | $('img').responsify(); 153 | }); 154 |
155 | Call responsify function again when the window is being resized (optional)
156 | 157 |$(window).resize(function(){ 158 | $('img').responsify(); 159 | }) 160 |
161 |
Contact Me
164 | 165 |-
166 |
- Follow @DesignJokes on Twitter 167 |
- Email zhangwenting111@gmail.com 168 |
Other Project by Wentin
171 | 172 |-
173 |
- Type Detail 174 |
- underline.js 175 |
- profession.is 176 |