Place an image at the top of a DIV and center it

前端 未结 6 1397
再見小時候
再見小時候 2021-01-24 08:53

I have 2 containers, one grey, one white. I\'d like to place an image (this will be a triangle down) to the very top of the white background and center it horizontally. How coul

6条回答
  •  醉梦人生
    2021-01-24 09:43

        .container{
    position:relative;
    }
    .triangle {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        top: -130px;
    }

提交回复
热议问题