day03

今天所学到的如下:

AM

1.盒子模型的传参

<style>
div{
            width: 100px;
            height: 100px;
            background: red;
            margin:100px 200px 300px;
   }
</style>

注释: margin:100px 四个方向全部改变
margin:100px 200px top,bottom--100px;left,right--200px
margin: 100px 200px 300px top--100px;right,left--200px;bottom--300px
margin: 100px 200px 300px 400px 按顺时针转

2.padding

<style>
div{
            width: 100px;
            height: 100px;
            background: red;
            padding:20px 30px 40px;
        }
</style>

注释:传一个参数 四个方向都改变
传两个参数 第一参数top,bottom;第二参数left,right
传三个参数 第一参数top;第二参数left,right;第三个参数bottom
传四个参数 top,right,bottom,left

3.

<style>
*{margin: 0;padding: 0}
        div{
            width: 300px;
            height: 300px;
            background: rebeccapurple;
            padding: 20px;
        }
</style>

注释:元素内容的起始位置,是基于它自身width,height的起始位置

4.标签的分类

<style>
        div{
            width: 100px;
            height: 100px;
            background: rebeccapurple;
            margin-top: 100px;
            margin-bottom: 100px;
        }
        a{
            width: 100px;
            height: 100px;
            background: rebeccapurple;
            margin-top: 100px;
            margin-bottom: 100px;
        }
        input{
            width:100px;
            height:100px;
            /* display:inline-block */
        }
    </style>


<body>
    <!--
        h1,p,div,ul,li,dl,dt,dd块标签
        特点:1.独占一行 2.能设置width,height
    -->
    <h1>h1</h1>
    <p>p</p>
    <ul>
        <li>1</li>
        <li>2</li>
    </ul>
    <dl>
        <dt>dt</dt>
        <dd>dd</dd>
    </dl>
    <div>div</div>
    <!--
        内联标签
        特点:1.并排显示 2.不能设置width,height 3.不能设置margin-top,margin-bottom
    -->
    <a href="#"></a> <span>span</span> <i>i</i> <em>em</em> <strong>strong</strong>
    <br>
    <!--
        内联块
        input,img,button
        特点:1.并排显示 2.能设置width,height
    -->
    <input type="text">
    <img src="images/icon1.png" alt="">
    <button>button</button>
</body>

5.

<style>
        /*
          内联元素和内联块元素水平居中
          {
              display:block;
              margin-left: auto;
              margin-right: auto;
          }
        */
        /*
          块标签默认display:block;
          内联默认 display:inline;
          内联块默认 display:inline-block
        */
        span{
            display: block;
            margin-left: auto;
            margin-right: auto;
            background: rebeccapurple;
            width: 100px;
        }
        img{
            display: block;
            margin-left: auto;
            margin-right: auto;
        }
    </style>


<body>
    <span>span</span>
    <br>
    <img src="images/icon1.png" alt="">
</body>

6.水平居中

 <style>
        body{
            text-align: center;
        }
    </style>


<body>
    <!--
        不改变内联和内联块的display属性 实现水平居中
        实现方案:
        parentElement{
        text-align:center;
    -->
    <span>span</span><br>
    <img src="images/icon1.png" alt="">
</body>

PM

1.分组选择器

<style>
        /*p{
            color:red;
        }
        */
        /*.one{
            color:red;
        }
        */
        /*.#two{
            color:red;
        }
        */
        /*伪装选择器*/
        /*
          p:hover{
              color:firebrick;
          }
        */
        /*分组选择器*/
        p,h1,div{
            color:aqua;
        }
    </style>


<body>
    <p class="one">hello world</p>
    <h1>h1</h1>
    <div>div</div>

2.后代选择器

<style>
        /*
           .parent>p{} 亲儿子
        */
        /*
           .parent>p{
            color: aquamarine;
        }
        */
        /*
           .parent>p{} 选择parent之后的所有p元素
        */
        .parent>p{
            color: aquamarine;
        }
    
    </style>


<body>
    <div class="parent">
        <p>hello world</p>
        <p>hello world</p>
        <div>
            <p>hello world</p>
        </div>
    </div>

    <div>
        <p>hello world</p>
    </div>
</body>

3.兄弟选择器

<style>
        /*
          兄弟选择器
          div+p{}-->选中div之后的第一个p元素

          div~p{}-->选中div之后的所有元素
        */
        /*
        div+p{
            color:tomato;
        }
         */
        div~p{
            color:tomato;
        }
        /*
          伪装类选择器
          */
        input:focus{
            background: pink;
        }
    </style>


<body>
    <div>div</div>
    <p>hello world</p>
    <p>hello world</p>
    <p>hello world</p>
    <p>hello world</p>
    <p>hello world</p>
    <p>hello world</p>
    <input type="text">
</body>

4伪元素

<style>
        /*
        伪元素-->用css自定义生产的元素
        div:before{
            content:"";
        }
        */
        div:before{
            width: 100px;
            height: 100px;
            background: red;
            content:"前面";
            display: block;

        }
        div:after{
            content: "后面";
            display: block;
            width: 100px;
            height: 50;
            background: yellow;
        }
    </style>
</head>
<body>
    <div>
        content
    </div>

5.属性

<style>
        /*
          属性选择器
          语法
          element[attr=value]
        */
        [class="one"]{
            color: yellowgreen;
        }
    </style>


<body>
    <p class="one">hello world</p>
</body>

6.选择器的优先级别

 <style>
        /*!important>id>class>p{} */
        p{
            color: red !important;
        }
        .one{
            color: yellow;
        }
        #two{
            color: green;
        }
    </style>

<body>
    <p class="one" id="two">hello world</p>
</body>

7.选择器的权重

<style>
        /* 选择器嵌套的层次越深,那么权重越高*/
        .child{
            color: red;
        }
        .parent>.child{
            color: green;
        }
    </style>
</head>
<body>
    <div class="parent">
        <div class="child">child</div>
    </div>
</body>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1.盒子模型的传参 《1.1》margin --margin:100px 四个方向全部改变-- margin:...
    小小全_阅读 175评论 0 2
  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML标准。 注意:讲述HT...
    kismetajun阅读 27,820评论 1 45
  • <!DOCTYPE html> * {margin: 0;padding: 0;} 首页> 预防装修材料...
    8eb783a6b522阅读 203评论 0 0
  • 各种纯css图标 CSS3可以实现很多漂亮的图形,我收集了32种图形,在下面列出。直接用CSS3画出这些图形,要比...
    剑残阅读 9,715评论 0 8
  • 飘零酒阅读 232评论 3 1