我不能设置背景图像到特定的div或body [英] I cant set a background-image to a specific div or body

查看:152
本文介绍了我不能设置背景图像到特定的div或body的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要为我建立的网站设定背景图片。我知道我必须使用 background:url(); ,但它似乎不显示它是否在 body div 。

 < body {
/ * background:linear-gradient(#2c3e50 75%,#ecf0f1 88%); * /
background:url(c:\Users\Saleh\Desktop\Abid\ggbridge960.png);
} / *这是它添加到body时的样子* /

.container {
margin:20px auto 20px auto;
/ * border:2px solid black; * /
width:960px;
height:1000px;
/ * background:url(c:\Users\Saleh\Desktop\Abid\ggbridge960.png)no-repeat; * /
} / *这是它在div中的样子。 * /

我已分别不同时尝试。



  body {
background:url(file:/// c:/Users/Saleh/Desktop/Abid/ggbridge960.png);
}


I'm trying to set a background image for the site I'm building. I know I have to use background: url(); but it doesn't seem to show up whether its in body or a specific div.

body {
    /* background: linear-gradient(#2c3e50 75%, #ecf0f1 88%); */
    background: url(c:\Users\Saleh\Desktop\Abid\ggbridge960.png);
} /* This is is what it looks like when I add it to body */

.container {
    margin: 20px auto 20px auto;
    /* border: 2px solid black; */
    width: 960px;
    height: 1000px;
    /* background: url(c:\Users\Saleh\Desktop\Abid\ggbridge960.png) no-repeat; */
} /* this is what it looks like in the div. */

I've tried them both separately not simultaneously.

解决方案

Do it like this..

body {
 background: url(file:///c:/Users/Saleh/Desktop/Abid/ggbridge960.png);
}

这篇关于我不能设置背景图像到特定的div或body的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆