相对定位的定位值

可以用left、right来描述盒子右、左的移动;

可以用top、bottom来描述盒子的下、上的移动。

↘:(右下)

position: relative;

top: 10px;

left: 40px;

↙:(左下)

position: relative;

right: 40px;

top: 10px;

↖:(左上)

position: relative;

right: 40px;

bottom: 10px;

↗:(右上)

position: relative;

right: -40px;

top: -40px;

等价于:

position: relative;
right: -40px;
bottom: 40px;
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .parent{
            width: 600px;
            height: 600px;
            margin: 0 auto;
            margin-top: 30px;
            border: 8px solid blue;
        }
        .son{
            width: 260px;
            height: 260px;
            background-color: orange;
             /* 相对定位的定位值 */
             position: relative;
             /* 右下 */
             /* top: 30px;
             left: 50px; */
             /* 左下 */
             /* top: 10px;
             right: 40px; */
             /* 左上 */
            /* right: 40px;
              bottom: 10px; */
             /* 右上 */
             right: -40px;
             bottom: 30px;
        }

.son2{
    width: 260px;
    height: 260px;
    background-color: pink;
}
</style>
</head>
<body>
    <div class="parent">
        <div class="son"></div>
        <div class="son2"></div>
    </div>
</body>

预览

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值