CSS: Semi-transparent background and an image

后端 未结 3 2074
无人及你
无人及你 2021-01-03 04:20
body {
  background-image: url(\'cloud.png\');
  background-color: rgba(255, 255, 255, 0.6);
}

I tried using the above to produce a semi-transparen

3条回答
  •  梦毁少年i
    2021-01-03 04:31

    I've done this using two separate images when announcing a special sale. One is the permanent image in the background and the other is a temporary sale image with semi-transparent background floated over the other image, that can be easily removed after the sale is over. The main div holding the background image needs to be Position:relative so you can position the semi-transparent image with position:absolute over the other image.

    Here is the HTML:

    banner
    Sale

    Here is the CSS:

    .tempsale {
        text-align:center; 
        position:relative;
    }
    .tempsaletext {
        positon:absolute; 
        top:10px; 
        left:20%; 
    }
    

    For more info, see full instructions here.

提交回复
热议问题