简体   繁体   English

在背景图像下重复背景颜色

[英]repeat background-color under background-image

I currently have an image that is a specific height and width, how would I set a specific color to run endlessly under the image. 我目前有一个特定的高度和宽度的图像,我如何设置特定的颜色以使其在该图像下无休止地运行。

body {
    background-image: location;
    background-color: #fff;
}

I'd like to background-color to be below the background-image and not all over the page but just under it. 我想将background-color设置在background-image的下方,而不是整个页面的下方,而是在其下方。

update 更新

html has background-color: #red html具有background-color:#red

body background-image: .png image & background-color: #fff; 身体背景图片:.png图片和背景颜色:#fff;

I'd like the background-color to not overflow the html color which is the top and just overflow under the background-image from the body. 我希望background-color不溢出顶部的html颜色,而只是从正文的background-image下溢出。

使用以下代码:

background:#ffffff url(ImageUrl) no-repeat;

Try this 尝试这个

background:red url(../img/s.jpg) no-repeat center top;

FIDDLE DEMO 现场演示

or 要么

background-color: red;/*...background colour..*/
background-image: url(../img/s.jpg);/*...image source...*/
background-position: center top;/*...position of background image...*/
background-repeat: no-repeat;/*...it will avoid repetition of image..*/

FIDDLE DEMO 现场演示

Use this one line code 使用这一行代码

body{
    background:#ffffff url('img_tree.png') no-repeat right top;
}

DEMO 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM