Make the image go behind the text and keep it in center using CSS

前端 未结 7 1484
粉色の甜心
粉色の甜心 2021-02-07 04:10

I am creating a web page, where I have an image that I want to place in the center. On the top of that image I want to have input boxes, labels, and a submit button.

I a

7条回答
  •  借酒劲吻你
    2021-02-07 04:40

    You can position both the image and the text with position:absolute or position:relative. Then the z-index property will work. E.g.

    #sometext {
        position:absolute;
        z-index:1;
    
    }
    image.center {
        position:absolute;
        z-index:0;
    }
    

    Use whatever method you like to center it.

    Another option/hack is to make the image the background, either on the whole page or just within the text box.

提交回复
热议问题