Skip to content

Commit 620f816

Browse files
author
zhangyonghong
committed
update
1 parent 17db886 commit 620f816

File tree

2 files changed

+54
-19
lines changed

2 files changed

+54
-19
lines changed

css.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -336,22 +336,4 @@ window.addEventListener("onorientationchange" in window ? "orientationchange" :
336336
//移动端的浏览器一般都支持window.orientation这个参数,通过这个参数可以判断出手机是处在横屏还是竖屏状态。
337337
```
338338

339-
- [iOS,Safari浏览器,input等表单focus后fixed元素错位问题](https://www.snip2code.com/Snippet/176582/--iOS-Safari----input---focus-fixed-----)
340-
```javascript
341-
if( /iPhone|iPod|iPad/i.test(navigator.userAgent) ) {
342-
$(document).on('focus', 'input, textarea', function()
343-
{
344-
$('header').css("position", 'absolute');
345-
$('footer').css("position", 'absolute');
346-
347-
});
348-
349-
$(document).on('blur', 'input, textarea', function()
350-
{
351-
$('header').css("position", 'fixed');
352-
$('footer').css("position", 'fixed');
353-
354-
});
355-
}
356339

357-
```

js.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,57 @@ WeixinJSBridge.invoke('getBrandWCPayRequest', d, function(res){
272272
});
273273
});
274274
})(jQuery);
275-
```
275+
```
276+
277+
- [iOS,Safari浏览器,input等表单focus后fixed元素错位问题](https://www.snip2code.com/Snippet/176582/--iOS-Safari----input---focus-fixed-----)
278+
```javascript
279+
if( /iPhone|iPod|iPad/i.test(navigator.userAgent) ) {
280+
$(document).on('focus', 'input, textarea', function()
281+
{
282+
$('header').css("position", 'absolute');
283+
$('footer').css("position", 'absolute');
284+
285+
});
286+
287+
$(document).on('blur', 'input, textarea', function()
288+
{
289+
$('header').css("position", 'fixed');
290+
$('footer').css("position", 'fixed');
291+
292+
});
293+
}
294+
295+
```
296+
297+
- 得到地理位置
298+
```javascript
299+
function getLocation(callback){
300+
if(navigator.geolocation){
301+
navigator.geolocation.getCurrentPosition(
302+
function(p){
303+
callback(p.coords.latitude, p.coords.longitude);
304+
},
305+
function(e){
306+
var msg = e.code + "\n" + e.message;
307+
}
308+
);
309+
}
310+
}
311+
```
312+
313+
- [rem计算适配](http://isux.tencent.com/web-app-rem.html)
314+
```javascript
315+
(function(doc, win){
316+
var docEl = doc.documentElement,
317+
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
318+
recalc = function(){
319+
var clientWidth = docEl.clientWidth;
320+
if(!clientWidth) return;
321+
docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';
322+
};
323+
324+
if(!doc.addEventListener) return;
325+
win.addEventListener(resizeEvt, recalc, false);
326+
doc.addEventListener('DOMContentLoaded', recalc, false);
327+
})(document, window);
328+
```

0 commit comments

Comments
 (0)