CakePHP,不显示 CSS 文件中的背景图像

发布于 2024-09-11 09:49:56 字数 551 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

信仰 2024-09-18 09:49:56

将图像放入 webroot/img

将 CSS 放入 webroot/css


在 CSS 样式中写入引用图像的相对路径:

background: url('../img/imagename.png');

Place images in webroot/img

Place CSS in webroot/css


Write relative paths to references images in CSS styles:

background: url('../img/imagename.png');
箹锭⒈辈孓 2024-09-18 09:49:56

您对 background 的拼写是错误的:

ackground-image: url('/root/Desktop/bg1.jpg');

如果实际代码中情况并非如此,请确保您指定了正确的路径,尝试在 之前添加一个点/根/

background-image: url('./root/Desktop/bg1.jpg');

You spelling for background is wrong:

ackground-image: url('/root/Desktop/bg1.jpg');

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/

background-image: url('./root/Desktop/bg1.jpg');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文