CakePHP,不显示 CSS 文件中的背景图像
Cakephp 给我带来了一些问题,因为我设置如下(我已经通过 localhost 尝试了任意数量的 url,将其放置在 webroot 中并从该文件中提供参考,给出来自 localhost 的完整路由(这是本地测试 ubuntu 机器,而不是第三方服务器)等,但它只是不显示。我正在使用覆盖默认布局的自定义布局,据我所知,它不包含对任何类型的背景图像的引用。 .这里来自我的css文件:
body {
background-image: url('http://localhost/site1/app/webroot/img/bg1.jpg');
font-family:'lucida grande',verdana,helvetica,arial,sans-serif;
font-size:90%;
}
我已经测试过这与常规HTML文件一起工作正常,我希望有人知道是什么蛋糕给我带来了这个问题..谢谢
编辑:我已经测试过并且我可以在同一个 css 文件的 DIV 中显示完全相同的图像(作为其背景)。Cakephp 中的某些内容覆盖了正文背景图像设置,但我不知道是什么。
Cakephp is giving me some problems as I have set as below (I have tried any number of urls, through localhost, placing it in webroot and giving reference from that file, giving full route from localhost (this is a local test ubuntu machine, not a 3rd party server), etc, etc but it just doesn't show up.. I am using a custom layout that overrides the default layout and, as far as I can tell, it contains no reference to any sort of background image.. here is from my css file:
body {
background-image: url('http://localhost/site1/app/webroot/img/bg1.jpg');
font-family:'lucida grande',verdana,helvetica,arial,sans-serif;
font-size:90%;
}
I have tested that this works fine with a regular HTML file, I am hoping someone has an idea of what cake is up to that is giving me this problem.. thanks
EDIT: I have tested and I can display exactly the same image within a DIV (as its background) from the same css file.. something in Cakephp is overriding the body background-image setting, but I can't figure out what.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将图像放入
webroot/img
将 CSS 放入
webroot/css
在 CSS 样式中写入引用图像的相对路径:
Place images in
webroot/img
Place CSS in
webroot/css
Write relative paths to references images in CSS styles:
您对 background 的拼写是错误的:
如果实际代码中情况并非如此,请确保您指定了正确的路径,尝试在
之前添加一个点/根/
You spelling for background is wrong:
If that is not the case in your actual code, make sure that you are specifying the correct path, try adding a dot before
/root/