0
点赞
收藏
分享

微信扫一扫

html学习

ixiaoyang8 2022-01-31 阅读 24

html学习

个人笔记,可复制源码再选取需要的元素

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>from表单标签</title>
</head>
<body>
<!--get方式提交 信息在url中显示 不安全高校
    post 方式提交 不显示比较安全,科传输大文件-->
<form method="get" action="1.我的第一个网页.html">

<!--表单内容-->
<!--<input>  输入框
type="text" 属性类型是文本
type="password" 类型是密码
value="lj" 框中大的默认初始值
size="30"  框的大小
maxlength="10 输入的最大字符串
hidden 隐藏输入框
readonly 只读不能更改
placeholder="请输入用户名” 提示输入
required 选框非空判断     -->
    <p>用户名:<input name="user name" type="text"value="lj" maxlength="10"placeholder="请输入用户名"required ></p>
    <p>&nbsp;&nbsp;&nbsp;码:<input name="pwd" type="password"hidden value="123456"></p>

<!--type = ”radio“ 单选框 必含value 值,name = ”sex“ 表示在同一组,同一组内只能单选
 checked 默认选中-->
    <p>&nbsp; &nbsp;&nbsp;性别:&nbsp; &nbsp;&nbsp;
        <input type="radio" value="boy" name="sex" checked/><input type="radio" value="girl" name="sex"/></p>

<!--type = "checkbox" 多选框
name="hobby" 多选框分同一个组
checked 默认选中-->
    <p>爱好:
        <input type="checkbox" name="hobby" value="game"/>游戏
        <input type="checkbox" name="hobby" value="code"checked/>代码
        <input type="checkbox" name="hobby" value="talk"a/>聊天
        <input type="checkbox" name="hobby" value="love"/>撩妹
    </p>

<!--type="button" 按钮
   type= "image"图片按钮 有提交的功能
   -->
    <p>
        <input type="button" name="bot1" value="走你"/>
        <input type="image" name="bot2" src="resources/img/98.png"/>
    </p>

<!--<select/> 下拉框
  <option/> 子选项
  selected  初始默认选择-->
    <p>下拉框:
        <select name="列表名称">
            <option value="china">中国</option>
            <option value="usa"selected>美国</option>
            <option value="jepan">日本</option>
            <option value="eluosi">俄罗斯</option>
        </select>
    </p>

<!-- <textarea/>文本域
cols="50" rows="20" 行和列-->
    <p>联系我们:
        <textarea cols="50" rows="20"/>留下您想说的:</textarea>
    </p>

<!--<input type="file" name="files"/>文件域 name 属性提交时可以在后天查看-->
    <p>文件域:
    <input type="file" name="files"/>
    <input type="button" value="上传"name="up">
    </p>
<!--自带验证的输入框
type="email 邮箱格式
type="url"  url 格式-->
    <p>邮件验证:
        <input type="email" name="email"/>
    </p>
    <p>URL验证:
        <input type="url" name="url"/>
    </p>
    <p>数字验证:
        <input type="number"max="100"min="1" step="any"/>
    </p>
    <p>日期选框:
        <input type="date" name="zhegnshu"/>
    </p>
    <p>音量滑块:
        <input type="range" name="voice"max="100" min="10" step="2"/>
    </p>
    <p>搜索框:
        <input type="search" name="search"/>
    </p>
<!--<label/>标签指向mark,text文本框锁定-->
    <p>锁定框:
        <label for="mark" >点我锁定</label>
        <input type="text" id="mark">

    </p>
    <p>自定义正则表达式验证:
        <input type="email" name="diyemail" pattern="^([A-Za-z0-9_\-\.\u4e00-\u9fa5])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,8})$"/>

    </p>

    <!--submit 属性是提交-->
    <!--reset   属性是重置 不能清空默认初始值
    disabled 禁用-->
    <p>
        &nbsp;&nbsp;<input type="submit"name="Button"value="提交">
        <input type="reset"name="reset"value="清空表单"disabled>
    </p>

</form>
</body>
</html>
![在这里插入图片描述](https://img-blog.csdnimg.cn/e176bd68df49443c87ba85ab10b082c4.png)

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #father{
            width: 310px;
            height: 320px;
            border: 2px solid red;
            padding: 2px;
        }
        a{
            display: block;
            height: 100px;
            width: 100px;
            border: 2px solid red;
            background-color: #ef09b6;
            line-height: 100px;
            text-align: center;
        }
        .a2,.a4{
            position: relative;
            left: 200px;
            top: -100px;
        }
        .a5{
            position: relative;
            top: -311px;
            left: 100px;
        }
        a:hover{
            background-color: #1e28de;
            color: white;

        }

    </style>
</head>
<body>
<div id="father">
    <a href="#" class="a1">链接1</a>
    <a href="#" class="a2">链接2</a>
    <a href="#" class="a3">链接3</a>
    <a href="#" class="a4">链接4</a>
    <a href="#" class="a5">链接5</a>
</div>
</body>
</html>

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #content{
            width: 100px;
            height: 150px;
            /*hidden 超出部分隐藏 auto scroll 超出部分滚动 */
            overflow: auto;
        }
    </style>
</head>
<body>
<div id="content">
    <img src="resources/img/21.png" alt="">
    <p>
        啊按规划绘画技巧org和;法国哈过后i发哈是好欸怀鬼胎的哈
    </p>

</div>
</body>
</html>

结构伪类选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
<!--结构伪类选择器的使用-->
    <style>
        ul li:first-child{
            background: #df0ce7;
        }
        ul li:last-child{
            background: aqua;
        }
        /*选择当前P标签的父级标签的第I个,和p相同*/
        p:nth-child(1){
            background: #136655;

        }
        /*鼠标点击后变色*/
        a:hover{
            background: chartreuse;
        }
    </style>
</head>
<body>
<a>这是a标签呢</a>
<p>p1</p>
<p>p2</p>
<p>[3</p>
<ul>
    <li>li1</li>
    <li>li2</li>
    <li>li3</li>
</ul>
</body>
</html>

居中登录的表单

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        h2 ul li body{
            /*body 外边距 内边距 划线有默认的初始化边距*/
            margin: 0px;
            padding: 0;
            text-decoration: none;
        }
        #box{
            width: 350px;
            height: 280px;
            background: red;
            display: table-cell;
            vertical-align: middle;

        }
        #inbox{
            width: 320px;
            height: 230px;
            background: white;
        }
        #but1{
            background: #ee0303;
            color: white;
            width: 230px;
            height: 30px;
            border-radius: 20px;
        }
        #p{
            line-height: 10px;
        }
        input{
            border-radius: 20px;
        }
        input[type="button"]{
            margin-top:10px;
            margin-left: 25px;;
            padding-left:0;
            /*text-align: left;*/
        }
    </style>
</head>
<body>
<div style=" width: 1000px;display: block;text-align: center;">
    <div align="center" style="margin: 0 auto">
        <div id="box" align="center" >
            <div id="inbox">
             <p id="p">
                    &nbsp;
            </p>
             <h2 id="h2">
                京东会员
             </h2>
                        <span >用户名:</span>
                <input value="请输入用户名" type="text">
                <p>
                <span>&nbsp;&nbsp;&nbsp;码:</span>
                <input  type="password">
                </p>
                <div>
                 <p>
                 <input type="button" value="登录" id="but1">
                 </p>
            </div>
         </div>
        </div>
    </div>
    </div>
</body>
</html>

属性选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .demo a{
            display: block;
            height: 50px;
            width: 50px;
            float:left;
            border-radius: 10px;
            background: blue;
            text-align: center;
            color: beige;
            text-decoration: none;
            margin-right: 5px;
            font: bold 20px/50px Arial;
        }
        /*属性名,属性名=属性值(正则)
        =表示绝对等于
        *=表示包含
        ^=表示以...开头
        $=表示以...结尾
        存在id属性的元素  a[]{}
        */
        /* a[id]{
             background: red;
         }*/

        /*id=first的元素*/
        /* a[id=first]{
             background: aqua;
         }*/

        /*class中有links元素*/
        /* a[class = "links item2 first2"]{
             background: orange;
         }*/
        /*a[class*="links"]{
            background: black ;
        }*/
        /*选中href中以http开头的元素*/
        a[href^="http"]{
            background: orange;
        }
    </style>

</head>
<body>
<p class="demo">
    <a href="http://www.baidu.com" class="links item first" id="first">1</a>
    <a href="/adad/faf" class="links item2 first2" >2</a>
    <a href="qwe123" class="links item3 first3" >3</a>
    <a href="eweqe" class="links item4 first4" >4</a>
    <a href="rrrrr" class="links item5 first5" >5</a>
    <a href="ttt" class="links item6 first6" >6</a>
    <a href="yyy" class="links item7 first7" >7</a>
</p>
</body>
</html>

id选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /* ID选择器的语法 #ID名称{}
        ID必须全局唯一
        不遵循就近原则,固定的
        优先级: ID选择器>class选择器> 标签选择器*/

        /*ID选择器*/
        #ll{
            color: #ee0303;
        }
        /*类选择器*/
        .tt{
            color: #df0ce7;
        }
        /*标签选择器*/
        h1{
            color: #0e4ff1;
        }
    </style>
</head>
<body>
<h1 id="ll">标题1</h1>
<h1>标题2</h1>
<h1 class="tt">标题3</h1>
<h1>标题4</h1>
<p>这个是标签</p>


</body>
</html>

层次选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*p{*/
        /*    background: aqua;*/
        /*}*/
        /*!*后代选择器*!*/
        /*body p{*/
        /*    background: #df0ce7;*/
        /*}*/
        /*子选择器,指向子代*/
        /*body>p{*/
        /*    background: darkorange;*/
        /*}*/
        /*相邻下一个同级选择器,只有下一个 语法:.类名+同类标签*/
        /*.yy+p{*/
        /*    background: blanchedalmond;*/
        /*}*/
        /*通用选择器,下面的所有同级的标签,不含自身*/
        .yy~p{
            background: #1f8bbd;
        }
    </style>
</head>
<body>
<p class="yy">p0</p>
<p>p1</p>
<p>p2</p>
<p>p3</p>
<p>p4</p>
<ul>
    <li>
        <p>p5</p>
    </li>
    <li>
        <p>p6</p>
    </li>
    <li>
        <p>p7</p>
    </li>
</ul>
<p class="yy">p8</p>
<p>p9</p>
<p>p10</p>
</body>
</html>

标签选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*标签选择器,会选择到页面上的所有这个标签的元素*/
        h1{color: #136655;
            background: aqua;
            border-radius: 30px; /*颜色,背景颜色,圆角*/
        }
        p{
            font-size: 80px;

        }

    </style>

</head>
<body>
<h1> 学习java</h1>
<h1> 学习线性代数</h1>
<p>好好学习</p>
<p>天天向上</p>
</body>
</html>

类选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*类选择器的格式 .class的名称{}
        好处:可以多个标签归类,是同一个class 可以复用,可以跨标签*/
        .lj{
            color: blue;
        }
        .ij{
            color: darkorange;
        }

    </style>
</head>
<body>
<h1 class="lj">标题1</h1>
<h1 class="ij">标题2</h1>
<h1 class="lj">标题3</h1>
<p class="lj">这是标签</p>
</body>
</html>

总结

在这里插入图片描述

有迟疑,有迷茫,我想要的很简单

举报

相关推荐

HTML学习

HTML基础学习

html学习小结

HTML学习笔记

html学习笔记

HTML学习3

HTML学习日记

html学习 菜鸟

0 条评论