CSS中的图片网址 [英] image url in CSS

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

问题描述

我只是想改变我的网站一点,但我碰到一个从来没有发生过我的问题。我想要能够离线测试网站,所以这个问题真的很烦人。

I was just trying to change my site around a little, but I bumped into a problem which has never happened me before. I want to be able to test the site offline, so this problem is really annoying.

如果我试图这样做:

#logo{
    width:145px;
    height:41px;
    background:url('http://biscuithead.ie/images/logo.png') center no-repeat;                           
    display:block;
    float:left;
    cursor:pointer;
}

它可以工作,但如果我将背景行更改为:

it works, but If I change the background line to:

background:url('/images/logo.png') center no-repeat;

background:url('images/logo.png') center no-repeat;

background:url(images/logo.png) center no-repeat;

background:url(/images/logo.png) center no-repeat;

it dosent工作?

it dosent work?

我使用DreamWeaver CS5。

I am using DreamWeaver CS5.

可以任何人帮助我们这个奇怪的问题?

Can anyone help we with this weird problem?

推荐答案

确保图像文件存在于您的计算机,

Be sure that the image file exists in your computer, and at the correct location.

没有前导斜线: images / logo.png 是相对于css文件的路径。如果css文件位于 /sites/example.com/css/styles.css ,则图像文件必须位于 /sites/example.com /css/images/logo.png

Without the leading slash: images/logo.png is a path relative to the css file. If the css file is at /sites/example.com/css/styles.css, the image file must be at /sites/example.com/css/images/logo.png (inside the "css" folder)

使用斜杠: images / logo.png 是相对于网站的根文件夹。如果css文件位于 /sites/example.com/css/styles.css ,则图像文件必须位于 /sites/example.com /images/logo.png (在网站根目录下)

With the leading slash: /images/logo.png is relative to the root folder of the site. If the css file is at /sites/example.com/css/styles.css, the image file must be at /sites/example.com/images/logo.png (inside the website root folder)

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

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