HTML基础二

一、HTML的新属性

 1、常用新标签总结:

  

·2、datalist 示例:

  2.1、datalist 中包裹 option

  2.2、datalist 与 input 关联后,input 就具备的 select 的效果,同时具有了输入联想功能。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>inputlist</title>
</head>
<body>
    <input type="text" value="请输入姓名" list="names">
    <datalist id="names">
        <option>张三</option>
        <option>李四</option>
        <option>王五</option>
    </datalist>

</body>
</html>

 

3、fieldset 示例:

  3.1、fieldset 默认宽度满屏

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>fieldset</title>
</head>
<body>
    <fieldset>
        <legend>用户登录</legend>
        用户名:<input type="text"/>
        <br/>
        密 码:<input type="password"/>
    </fieldset>
</body>
</html>

 

 

 4、新增的input type属性

   4.1、这些新增的类型,更加细化的限定了输入内容,如果输入格式不对,在提交的时候会自动给出相应提示

 

  4.2、代码实现

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>newInputType</title>
</head>
<body>
    <form action="http://www.baidu.com">
        email:<input type="email"/>
        <br/>
        tel:<input type="tel"/>
        <br/>
        url:<input type="url"/>
        <br/>
        number:<input type="number"/>
        <br/>
        search:<input type="search"/>
        <br/>
        range:<input type="range"/>
        <br/>
        time:<input type="time"/>
        <br/>
        date:<input type="date"/>
        <br/>
        datetime:<input type="datetime-local"/>
        <br/>
        month:<input type="month"/>
        <br/>
        week:<input type="week"/>
        <br/>
        color:<input type="color"/>
        <br/>
        <input type="submit"/>
    </form>
</body>
</html>

 

  4.2、新增的 input 属性

  代码实现

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>newInputAttr</title>
</head>
<body>
    <form action="form.html">

        <input type="text" placeholder="请输入用户名"/>
        <br/>
        <br/>
        <!--可以简化为 <input type="text" autofocus/>  -->
        <input type="text" autofocus="autofocus" placeholder="自动获取焦点"/>
        <br/>
        <br/>
        <input type="file" multiple/>
        <br/>
        <br/>
        <input type="text" autocomplete name="identify" placeholder="下次自动补足输入内容"/>
        <br/>
        <br/>
        <!--在火狐浏览器中,如果没有输入内容,点击输入框外部区域,边框会变红-->
        <input type="text" required placeholder="这是必填项"/>
        <br/>
        <br/>
        <input type="text" accesskey="s" placeholder="获取焦点的快捷键为 alt+s"/>
        <br/>
        <br/>
        <input type="submit"/>
    </form>
</body>
</html>

 

 

 5、综合效果图

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test1</title>
</head>
<body>
    <form action="">
        <fieldset>
            <legend>学生档案</legend>
            <label>姓  名:<input type="text" placeholder="请输入学生姓名"/></label> <br/>
            <label>手 机 号:<input type="tel" placeholder="请输入学生手机号"/></label><br/>
            <label>邮  箱:<input type="email"/></label><br/>
            <label>所属学院:<input type="text" list="academy"/></label>
            <datalist id="academy">
                <option >JAVA学院</option>
                <option >前端学院</option>
                <option >PHP学院</option>
            </datalist><br/>
            <label>出生日期:<input type="date"/></label><br/>
            <label>语文成绩:<input type="number" max="100" min="0" value="0"/></label><br/>
            <label>数学成绩: <meter max="100" min="0" low="59" value="10"></meter></label><br/>
            <label>英语成绩: <meter max="100" min="0" low="59" value="90"></meter></label><br/> # low表示过了就变颜色
            <input type="submit"><br/>
            <input type="reset">

        </fieldset>
    </form>
</body>
</html>

 

 

posted @ 2019-06-04 15:17  独角兕大王  阅读(136)  评论(0)    收藏  举报