• 欢迎光临~

前端3+1(Day14)

开发技术 开发技术 2022-01-23 162次浏览

前端3+1(Day14)

为什么HTML5只需要写

因为HTML4中的doctype需要对DTD进行引用,因为HTML4.0基于SGML。

而HTML5不基于SGML,不需要对DTD进行引用,但是需要doctype来规范浏览器行为

SGML是比HTML,XML更老的标准,这两者都是由SGML发展而来。

position:fixed,在ios端失效的原因,解决措施

软键盘被唤起时,fixed失效,就可以理解为position:absolute,这时当页面超过一屏时,就会跟着页面相互滚动了

方法一:

<body class="layout-scroll-fixed">
    <!-- fixed定位的头部 -->
    <header>
        
    </header>
    
    <!-- 可以滚动的区域 -->
    <main>
        <div class="content">
        <!-- 内容在这里... -->
        </div>
    </main>
    
    <!-- fixed定位的底部 -->
    <footer>
        <input type="text" placeholder="Footer..."/>
        <button class="submit">提交</button>
    </footer>
</body>
header, footer, main {
    display: block;
}

header {
    position: fixed;
    height: 50px;
    left: 0;
    right: 0;
    top: 0;
}

footer {
    position: fixed;
    height: 34px;
    left: 0;
    right: 0;
    bottom: 0;
}

main {
    /* main绝对定位,进行内部滚动 */
    position: absolute;
    top: 50px;
    bottom: 34px;
    /* 使之可以滚动 */
    overflow-y: scroll;
}

main .content {
    height: 2000px;
}

方法2:

我们可以使用isScroll.js来实现内部滚动,这个只可以时Android2.3以下的

什么是闭包,闭包的优缺点

闭包定义:就是函数A嵌套函数B,函数B使用函数A的内部变量,函数A将函数B作为返回值。

优点:防止内在变量污染作用域

缺点:不释放,会导致内存泄漏

你最喜欢的编辑器,理由

程序员灯塔
转载请注明原文链接:前端3+1(Day14)
喜欢 (0)
违法和不良信息举报电话:022-22558618 举报邮箱:dljd@tidljd.com