Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用背景图像的HTML、CSS_Html_Css - Fatal编程技术网

使用背景图像的HTML、CSS

使用背景图像的HTML、CSS,html,css,Html,Css,我想弄清楚这件事已经有一段时间了。正在尝试使用css添加背景图像。我也在使用bootstrap。这是我的密码 css: html: 问题: 图像不会显示在我的页面上 .container-fluid{ position:absolute; background-image: url('DomPic/photo1.jpg'); height: 100%; width: 100%; } 新增位置:绝对位置;对于现有代码,这是因为您的div没有任何内容 <div class="contai

我想弄清楚这件事已经有一段时间了。正在尝试使用css添加背景图像。我也在使用bootstrap。这是我的密码

css:

html:


问题: 图像不会显示在我的页面上

.container-fluid{
position:absolute;
background-image: url('DomPic/photo1.jpg');
height: 100%;
width: 100%;
}

新增位置:绝对位置;对于现有代码,这是因为您的div没有任何内容

<div class="container-fluid">Something</div>

添加
位置:绝对位置
.container fluid
类。。 就这么简单

注意:在div中添加一些内容可以根据div的内容调整背景。

试试这个:

 .container-fluid{
background-image: url('http://s13.postimg.org/51s3l0x3b/w3schools.png');
background-repeat: repeat-y;
height: 100%;
width: 100%;
}

看来您的图片路径错误

您不需要将路径设置为C:。。。。 只是

背景图像:url('just../assets/img.piture.png或./picture.png或picture.png')
取决于图片在项目中的位置。
前

myproject/assets/images/picture.png。。等等

下面的例子很有效

。容器流体{
背景图像:url('http://www.fillmurray.com/100/100');
高度:100px;
宽度:100px;
}

尝试在您的风格中使用可能会对您有所帮助

.container-fluid
    {
    position:absolute;
    background-image: url('DomPic/photo1.jpg');
    height: 100%;
    width: 100%;
    background-size:contain;
    }

相反,这是一个错误的形象。请再查一下

background-image: url('folder/picture.jpg');

请输入完整代码?那是我的完整代码。图像不会显示在我的页面上C:\Users\muna\Desktop\DomWebsite\DomPic这是我的路径。但是我很确定我输入了正确的路径;在div中添加任何文本或内容。他没有详细解释他的问题,也没有提供详细信息。stackoverflow中说“提供详细信息。分享你的研究。”在评论中提供细节不是一个好主意。他应该编辑问题以提供更多细节。这样其他阅读问题的人就可以理解他的问题。我有这个,它可以工作,但我的图像仍然缩小到很多。你可以添加:背景大小:包含;
 .container-fluid{
background-image: url('http://s13.postimg.org/51s3l0x3b/w3schools.png');
background-repeat: repeat-y;
height: 100%;
width: 100%;
}
.container-fluid
    {
    position:absolute;
    background-image: url('DomPic/photo1.jpg');
    height: 100%;
    width: 100%;
    background-size:contain;
    }
background-image: url('folder/picture.jpg');