day05

作者: 消暑绿豆汤 | 来源:发表于2018-07-19 08:50 被阅读0次

    今天学到的

    相对定位,绝对定位
    position:relative;absolute;
    //相对定位就是元素对于整个网页位置是正常的;
    //绝对定位就是子元素相对于父元素的位置(离他最近的父元素);
    //传参有:top:;bottom:;left:;right:;
    
    垂直水平居中
    .parent{
    position:relative;
    height:300px;
    width:300px;
    background:red;
    }
    .child{
    position:absolute;
    height:50px;
    width:50px;
    background:green;
    top:50%;
    left:50%;
    margin-top:-25px;
    margin-left:-25px;
    }
    
    banner
    //子元素的top,left值给的百分比是相对于父元素
    html,body{
    height:100%;
    width:100%;
    }
    img{
    height:;
    width:;
    position:absolute;
    top:50%;
    left:50%;
    }
    body{
    position:relative;
    }
    
    position:z-index;//z-index设置给了absolute定位元素的堆叠顺序
    

    相关文章

      网友评论

          本文标题:day05

          本文链接:https://www.haomeiwen.com/subject/sffwpftx.html