button position absolute not working as expected

后端 未结 7 1365
礼貌的吻别
礼貌的吻别 2021-02-20 05:49

Can anyone explain why this button is not absolute-positioned to the right? I would expect it to be 3px from every edge.

7条回答
  •  悲哀的现实
    2021-02-20 06:14

    please use below css ..

    .wrapper {
        height: 300px;
        width: 300px;
        background-color: #f33;
        position: relative;
        padding: 3px
    }
    .wrapper button {
        position: absolute;
        top: 0;
        bottom:0;
        left:0;
        right:0;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        width:100%;
    }
    

提交回复
热议问题