Can I apply multiple background colors with CSS3?

后端 未结 6 2065
死守一世寂寞
死守一世寂寞 2020-11-27 06:13

I know how to specify multiple background images using CSS3 and modify how they are displayed using different options.

Currently I have a

, w
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 06:53

    Yes its possible! and you can use as many colors and images as you desire, here is the right way:

    body{
    /* Its, very important to set the background repeat to: no-repeat */
    background-repeat:no-repeat; 
    
    background-image:  
    /* 1) An image              */ url(http://lorempixel.com/640/100/nature/John3-16/), 
    /* 2) Gradient              */ linear-gradient(to right, RGB(0, 0, 0), RGB(255, 255, 255)), 
    /* 3) Color(using gradient) */ linear-gradient(to right, RGB(110, 175, 233), RGB(110, 175, 233));
    
    background-position:
    /* 1) Image position        */ 0 0, 
    /* 2) Gradient position     */ 0 100px,
    /* 3) Color position        */ 0 130px;
    
    background-size:  
    /* 1) Image size            */ 640px 100px,
    /* 2) Gradient size         */ 100% 30px, 
    /* 3) Color size            */ 100% 30px;
    }

提交回复
热议问题