CSS:在CSS中设置背景图片 [英] CSS: Setting background-image in CSS

查看:115
本文介绍了CSS:在CSS中设置背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CSS中设置背景图像时正确的语法是什么?自从出现以来,在Visual Studio中,背景似乎没有问题.但是在像IE或FF这样的浏览器中,背景不会出现.我在这里错过了什么吗?

What is the correct syntax when setting the background-image in CSS? In visual studio, there seems to be no problem in the background since it appears. But in the browser like IE or FF, the background does not appear. is there something i missed here?

我正在使用的语法如下(我认为这是正确的...)

syntax i am using is below (which i think is correct...)

#headerArea
{
    height: 150px;
    background-image: url('/images/bgimage.jpg');
}

以上是正确的对吗?

推荐答案

根据您的文件夹结构以及CSS相对于所使用图像的位置,您将必须升至图像目录的根目录,然后从那里访问它,所以您可以尝试类似

Depending on your folder structure and where the CSS is located relative to the images it is using you will have to go up to the root level of the image directory and access it from there so you could maybe try something like

background-image: url('/../images/bgimage.jpg');

这篇关于CSS:在CSS中设置背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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