• 页面结构分析


    本次博客带领大家学习HTML中的页面结构分析。

    元素名描述
    header标题头部区域的内容(用于页面或页面中的一块区域)
    footer标记脚部区域的内容(用于整个页面或页面中的一块区域)
    sectionWeb页面中的一块独立区域
    article独立文章内容
    aside相关内容或应用(常用于侧边栏)
    nav导航类辅助内容

    iframe内联框架

    请添加图片描述

    • 还可以使用a标签来使内容跳转到iframe内联框架中。
    <iframe src="" name="hello" frameborder="0" width="1000px" height="800px">iframe>
    
    <a href="//player.bilibili.com/player.html?aid=55631961&bvid=BV1x4411V75C&cid=97257627&page=10" target="hello">点击跳转a>
    
    • 1
    • 2
    • 3

    表单语法

    请添加图片描述

    <h1>注册h1>
    
    
    
    <form action="firstHtml.html" method="post">
    
        
        <p>名字:<input type="text" name="username">p>
        
        <p>密码:<input type="password" name="pwd">p>
    
        <p>
            <input type="submit">
            <input type="reset">
        p>
    form>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    表单元素格式

    属性说明
    type指定元素的类型。text、password、checkbox、radio、submit、reset、file、hidden、image和button,默认为text
    name指定表单元素的名称
    value元素的初始值。type为radio时必须指定一个值
    size指定表单元素的初始宽度。当type为text或password时,表单元素的大小以字符为单位。对于其他类型,宽度以像素为单位
    maxlength当type为text或password时,输入的最大字符数
    checked当type为radio或checkbox时,指定按钮是否是被选中
    
    <p>名字:<input type="text" name="username" value="1111" maxlength="8" size="30">p>
    
        
        <p>性别:
            <input type="radio" value="boy" name="sex"><input type="radio" value="girl" name="sex">p>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    多选框和按钮

    • 多选框使用的是input type="checkbox"类型,记得设置在同一个name中。
    
    <p>爱好:
        <input type="checkbox" value="sleep" name="hobby">睡觉
        <input type="checkbox" value="code" name="hobby">敲代码
        <input type="checkbox" value="chat" name="hobby">聊天
        <input type="checkbox" value="game" name="hobby">游戏
    p>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 普通按钮使用的是input type="button"类型,给按钮设置内容是使用value。
    
    <p>按钮:
        <input type="button" name="btn1" value="点击边长">
        <input type="image" src="../resources/image/1.JPG" width="300px" height="300px">
    p>
    
    <p>
        <input type="submit">
        <input type="reset" value="点击清空表单">
    p>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    列表框、文本域和文件域

    • 列表框:使用的是标签,列表里面的内容使用加载。
    
    <p>下拉框:
        <select name="列表名称" >
            <option value="china">中国option>
            <option value="us">美国option>
            <option value="eth" selected>瑞士option>
            <option value="yindu">印度option>
        select>
    p>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 文本域:使用的是标签,其中的cols属性表示占多少列,rows属性表示占多少行。
    
    <p>反馈:
        <textarea name="textarea" id="" cols="50" rows="10">文本内容textarea>
    p>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 文件域:使用的是input type="file"标签。
    
    <p>
        <input type="file" name="files">
        <input type="button" value="上传" name="upload">
    p>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    搜索框、滑块和简单验证

    • 搜索框:使用的是input type="search"标签。
    
    <p>搜索:
        <input type="search" name="search">
    p>
    
    • 1
    • 2
    • 3
    • 4
    • 滑块:使用的是input type="range"标签。
    
    <p>音量:
        <input type="range" name="voice" min="0" max="100" step="2">
    p>
    
    • 1
    • 2
    • 3
    • 4
    • 简单验证:邮箱验证、URL、数字验证等等。
    
    <p>邮箱:
        <input type="email" name="email">
    p>
    
    <p>URL:
        <input type="url" name="url">
    p>
    
    <p>数字:
        <input type="number" name="num" max="100" min="0" step="1">
    p>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    表单的应用

    • 标记只读使用的是readonly。
    <p>名字:<input type="text" name="username" value="1111" readonly>p>
    
    • 1
    • 标记禁止使用的是disabled。
    <input type="radio" value="boy" name="sex" checked disabled>
    • 1
    • 隐藏标签使用的是hidden。
    <p>密码:<input type="password" name="pwd" hidden>p>
    
    • 1
    • 增强鼠标的可用性,点击文字就能跳转到对应的文本框,使用标签,记得添加好对应的id属性。
    
    <p>
        <label for="mark">你点我试试:label>
        <input type="text" id="mark">
    p>
    
    • 1
    • 2
    • 3
    • 4
    • 5

    表单的初级验证

    • 文本框的提示信息用placeholder属性。
    <p>名字:<input type="text" name="username" placeholder="请输入用户名">p>
    
    • 1
    • 文本框填充不能为空使用required属性。
    <p>名字:<input type="text" name="username" placeholder="请输入用户名" required>p>
    
    • 1
    • 判断文本框中的信息可以使用正则表达式pattern属性。(正则表达式可以直接在网站中查询)
    <p>自定义邮箱:
        <input type="text" name="diymail" pattern="^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$">
    p>
    ut type="text" name="username" placeholder="请输入用户名" required>p>
    
    • 1
    • 2
    • 3
    • 4
  • 相关阅读:
    设计模式之单例模式
    bcc和ftrace追踪内核网络模块实战
    .NET 数据库大数据操作方案(插入、更新、删除、查询 、插入或更新)
    Arcgis 定义投影、投影变换、导出栅格为tif、矢量转tif
    模型放到gpu上训练
    华为配置蓝牙终端定位实验
    Java Class09
    终于找到你!数字化时代的秘密武器
    2021年InfoWorld 精选最佳开源软件
    图片、视频修复并超分 - Real-ESRGAN项目使用(一) | 机器学习
  • 原文地址:https://blog.csdn.net/lidong777777/article/details/126163638