CSS placing one image on top of another

后端 未结 7 2103
闹比i
闹比i 2020-12-10 11:17

I am working on CSS design template.

I have two images imageOne and imageTwo.

Both are position: relative because if I

7条回答
  •  一生所求
    2020-12-10 11:32

    If you have a responsive image in a container and want to place another image on top of that image:

    HTML:

    .container {
      position: relative;
      width: 100px;/*Or whatever you want*/
    }
    .imageOne {
      width: 100%;
    }
    .imageTwo {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }

提交回复
热议问题