什么是......有点困惑我,我是网络新手 [英] What Is .. Little Confuse Me,, I Am New To Web

查看:63
本文介绍了什么是......有点困惑我,我是网络新手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在外部样式表中使用

body {



background-image:url(images / bg-body.png) ;

}



没有添加图片但是当我使用它而不是上面时



background-image:url(../ images / bg-body.png);



i use ..之前/ images目录



图像是在后台加载的,



那么什么(......这个点在这里对我有用,

when i use in external stylesheet that
body{

background-image: url(images/bg-body.png);
}

no image is added but when i use this instead of above

background-image: url(../images/bg-body.png);

i use .. before /images directory

the image is loaded in background,,

so what (.. this dots means here that worked for me,

推荐答案

除了解决方案1:



最有可能的,你想要实现的是引用你的 bg-body.png相对于为您的网站设置的根目录。正确的语法是〜/ images / bg-body.png。



路径/images/bg-body.png是不同的;这是一个相对于当前点的路径,即引用此文件的文件的位置。它假定该目录,即HTML文件所在的目录e位于,具有子目录images,并且该子目录具有文件bg-body.png。显然,在你的例子中,情况并非如此。



在像你这样的情况下,使用他的〜/站点 - 全局路径给你一个好处维护:当您以这种方式移动引用图像文件的HTML文件时,如果不移动包含图像的目录,则引用仍然有效。使用相对寻址(在许多其他情况下最好),如果您以某种方式更改其位置,例如,可能是其目录的深度,则需要在HTML文件中编辑它们。



-SA


..



指的是当前目录的父级


refers to the parent of the current directory

parent directory (..) ----
                         |----images directory ----
                         |                        |
                         |                    bg-body.png
                         | 
                         |----webpage directory ---
                                                  | 
                                yourpage.html (referencing the bg-body.png)



了解更多: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v = VS .85).aspx #fully_qualified_vs._relative_paths [ ^ ]


这篇关于什么是......有点困惑我,我是网络新手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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