美文网首页
web学习CSS7:CSS定位(position)

web学习CSS7:CSS定位(position)

作者: TDB | 来源:发表于2019-05-09 22:49 被阅读0次

1.postion之staic

:nth-child(n) ---->选中某个元素,该元素必须是某个父元素下的第n个子元素

2.postion之relative

相对于自己原来位置坐偏移
z-index:可用于将在一个元素放置于另一元素之后

3.postion之absolute

相对最近的relative布局
    .parent {
        position: relative;
        width: 200px;
        height: 150px;
        background: blue;
    }

    .child {
        position: absolute;
        width: 80px;
        height: 80px;
        background: red;
        right: -80px;
        top:0;
    }

垂直居中:
    .child {
        position: absolute;
        width: 80px;
        height: 80px;
        background: red;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        margin: auto auto;
    }

4.positon之fixed

5.poistion之sticky(CSS3)


相关文章

网友评论

      本文标题:web学习CSS7:CSS定位(position)

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