前端开发常见问题记录

记录一些踩过的坑,全是经验......

一:ipone

1.readonly与disabled

 在iphone下,输入框为readonly时,点击依然会获得焦点;

建议设为disabled

2.button在iphone下会有默认自带的样式和圆角

-webkit-appearance: none;清除自带样式

3.button,a,img等点击时会高亮,去除方式如下:

-webkit-tap-highlight-color:rgba(255,255,255,0);

4.不兼容new date("2017-09-08 00:00:00")  这种写法,需要把‘-’换成‘/’:

var date="2017-09-08 00:00:00"

new Date(date.replace(/-/g, "/"))

二:android

1.输入框获取焦点时,软键盘会遮挡,主动触发让输入框上移

if (/Android/gi.test(navigator.userAgent)) {
    window.addEventListener('resize', function () {
        if (document.activeElement.tagName == 'INPUT' || document.activeElement.tagName == 'TEXTAREA') {
            window.setTimeout(function () {
                document.activeElement.scrollIntoViewIfNeeded();
            }, 0);
        }
    })
}

猜你喜欢

转载自www.cnblogs.com/lichunyan/p/8214600.html