美文网首页
day6(定位)

day6(定位)

作者: 很普通的人 | 来源:发表于2018-07-16 20:17 被阅读0次

    相对定位

    • 1相对定位是相对自己的原本的位置定位
      position:relative;

    绝对定位

    • 2在父级的基础上的绝对的位置(与其给了定位的离得最近的父级)
      position:absolutive;

    • 3div悬浮在屏幕上
      position:fixed;

    • 4搜索框格式

          <div class="search">
            <input> 
            <button></button>
          </div>
      
    • 5 定位垂直居中


      1.png
     .parent{
                position: relative;
                width:300px;
                height:300px;
                background:red;
            }
            .child{
                position:absolute;
                width:50px;
                height:50px;
                background:green;
                left:50%;子元素left,top值给百分比,是相对于父元素的width,height而言的
                top:50%;
                margin-left:-25px;(height的一半)
                margin-top: -25px;
            }
    
    
    • 6弧度
      border-radius
    • 7堆叠顺序
      z-index
      设置给了absolute定位元素的堆叠顺序
      数字越大,顺序越前,越先显示

    相关文章

      网友评论

          本文标题:day6(定位)

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