transparent background image

后端 未结 5 1696
暗喜
暗喜 2020-12-31 04:05

I have the following css.

   #mypass{
                background-image: url(\"Images/logo.png\");
                background-attachment: fixed;
                      


        
5条回答
  •  情书的邮戳
    2020-12-31 04:47

    The element that needs to have semi-transparent background:

    #myPass
    

    This is how without touching the HTML, we add controllable transparency background to the element:

    #myPass::before {
        content: "";
        position: absolute;
        top: 0; right: 0;
        bottom: 0: left: 0;
        background: url(image.jpg) no-repeat top center;
        opacity: 0.5;
    }
    

    The only thing to note is that the #myPass element, must be positioned:

    #myPass {
        position: relative; /* absolute is good too */
    }
    

提交回复
热议问题