day6

1.样式的引用

1.内部样式表
<style>
        .two{
            width:100px;
            height:100px;
            background:green;
        }
    </style>
</head>
<body>
    <div></div>
    <div  class="two"></div>
2.内联样式
<div style="width:100px;height:100px;background: red"></div>
    <div  class="two"></div>
3.外部引用
  <link rel="stylesheet" href="css/index.css">
</head>
<body>
    <div class="test"></div>
</body>
外部创建一个css文件:
.test{
    width:100px;
    height:100px;
    background:red;
}

2.路径

        相对路径 相对于同级目录下的
        绝对路径 图片的绝对地址 (最好不要使用)
   
     <!-- 同级目录 -->
     <img src="down.jpg" alt="">
     <!-- 下一级目录 -->
     <img src="images/location.png" alt="">

3.width和heigth的继承

1.子元素绝对定位,不会继承父元素的width
 <style>
        /*  */
        .parent{
            width:100px;
            height:100px;
            background: red;
            position: relative;
        }
        .child{
            height:50px;
            background: green;
            position:absolute;
        }
    </style>
</head>
<body>
    <div class="parent">
        <div class="child">

        </div>
    </div>
</body>
1.png
2.子元素绝对定位,父元素没有heigth
  <style>
        .parent{
            width:200px;
            /* height:200px; */
            background: red;
        }
        .child{
            position:absolute;
            width:100px;
            height:100px;
            background: green;
        }
    </style>
</head>
<body>
    <div class="parent">
        <div class="child"></div>
    </div>
</body>
1.png

4.bug

 <style>
        /* 子元素作为父元素的第一个元素,给它margin-top,没用
        它的元素向下移动
         */
        .parent{
            width:200px;
            height:200px;
            background:red;
        }
        .child{
            margin-top: 50px;
            width:100px;
            height:100px;
            background:green;
        }
        /*如何解决*/
        .row:before{
            content:"";
            display: table;
        }
    </style>
</head>
<body>
    <div class="parent row">
        <div class="child"></div>
    </div>
</body>
 <style>
        /* 浪潮之巅 */
        /* 
        margin重合的问题
         */
        .one{
            width:100px;
            height:100px;
            background:red;
            margin-bottom: 150px;
        }
        .two{
            margin-top: 100px;
            width:100px;
            height:100px;
            background-color: yellow;
        }
    </style>
</head>
<body>
    <div class="one"></div>
    <div class="two"></div>
</body>
1.png

5.表单

<body>
    <h4>一个简单的登录表单</h4>
    <form >
        <!-- label和input结合使用  要点:label的for的值要和input的id一样 -->
        <div>
            <label for="user">用户名</label><input type="text" id="user">
        </div>
        <div>
            <label for="pwd">密码</label><input type="password" id="pwd">
        </div>
        <div>
            <input type="submit" value="提交">
        </div>
        <div>
            <!-- 技术要点:name值相同 -->
            <h4>性别</h4>
            <label for="male">男</label><input type="radio" id="male" name="sex">
            <label for="female">女</label><input type="radio" id="female" name="sex">
        </div>
        <div>
            <!-- type=checkbox  复合选框 -->
            <input type="checkbox">足球
            <input type="checkbox">篮球
            <input type="checkbox">羽毛球
        </div>
        <div>
            <!-- 下拉选框 -->
            <select >
                <option value="武昌区">武昌区</option>
                <option value="洪山区" selected>洪山区</option>
                <option value="青山区">青山区</option>
            </select>
        </div>
    </form>
    <textarea placeholder="请吐槽" cols="30" rows="10"></textarea>
    <!-- 大于,空格,大于 的字符 -->
    <div>&lt;&nbsp;&gt;</div>
</body>
1.png

text,btn的区别

    <style>
        *{margin:0;padding:0}
        input{
            border:1px solid #333;
            width:100px;
            height:40px;
        }
        .btn{
            width:102px;
            height:42px;
        }
        /* input是按钮的形态下,给border,padding不会改变它的width,height */
    </style>
</head>
<body>
    <!-- 输入框和按钮的区别 -->
    <input type="text"> <br>
    <input type="submit" class="btn">
    <!-- <button type="submit">提交</button> -->
</body>
1.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 13,863评论 1 92
  • HTML 5 HTML5概述 因特网上的信息是以网页的形式展示给用户的,因此网页是网络信息传递的载体。网页文件是用...
    阿啊阿吖丁阅读 4,171评论 0 0
  • # 第一优先级规则声明: # 除了梦境,每一个意识主进程都必须与一个身体参与的机械进程相匹配,否则结束意识主进程。...
    李洞BarryLi阅读 3,954评论 0 1
  • 转载请声明 原文链接地址 关注公众号获取更多资讯 第一部分 HTML 第一章 职业规划和前景 职业方向规划定位...
    前端进阶之旅阅读 16,675评论 32 459
  • 1. Spring MVC简介 Spring MVC提供model-view-controller架构和已有组件,...
    Java_Explorer阅读 881评论 0 1