Larger div centered inside smaller div

前端 未结 3 1228
鱼传尺愫
鱼传尺愫 2021-02-08 00:47

I have a div (#containment) inside another div (#edit). The outer div is smaller. The inner div\'s size will be changed by some jQuery code.

3条回答
  •  -上瘾入骨i
    2021-02-08 01:29

    Yes. You can do that.

    #edit{
        width:200px;
        height:200px;
        overflow:visible;
        margin:200px 0 0 200px;
        background:gray;
        position : relative;
    }
    #containment{
        width:500px;
        height:500px;
        opacity:0.5;
        background:red;
        position : absolute;
        top : -150px;
        left : -150px;
    }
    

    Demo: http://jsfiddle.net/fzAge/2/

提交回复
热议问题