在 magento 的 CMS 页面中使用静态块时没有 CSS

发布于 2024-12-15 07:22:13 字数 181 浏览 3 评论 0原文

我有一个静态块作为主题的一部分,可以在主页上完美运行 - 但是当我将静态块添加到任何其他页面时,它会以不同的方式显示。基本上,CSS 不遵循块,而且看起来也不像应有的那样。该块包含主题提供的小部件,那么我是否正确地说创建小部件时应附加 CSS?

有没有办法强制 CSS 遵循块而不用过多地摆弄核心文件?或者有人能看到我忽略的东西吗?

I have a static block as part of a theme that works perfectly on the homepage - but when I add the static block to any other page it displays differently. Basically the CSS doesn't follow the block and it looks nothing like it should. The block contains a widget provided by the theme, so am I correct saying the CSS should be attached when the widget is created?

Is there anyway to force the CSS to follow the block without fiddling too much with the core files? Or can anyone see something I am overlooking?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

隐诗 2024-12-22 07:22:14

您不能强制 CSS “跟随”该块 - 您能做的最好的事情就是确保所需的 CSS 已加载到您想要的页面上。

您有几个选择:

  • 将您正在使用的 CSS 复制/移动到使用静态块加载到所有页面上的 CSS 文件中(例如,boxs.css)
  • 在使用静态块的所有页面上包含主页使用的样式表(尽管这可能会产生副作用)
  • 将 CSS 添加到

你是对的,最好避免摆弄 Magento 的核心文件,但你应该能够只编辑主题文件,这些文件不被视为核心代码,并且想必你已经这样做了以自定义外观。

You can't force the CSS to 'follow' the block - the best you can do is make sure the required CSS is loaded on the pages you want.

You have a few options:

  • Copy/move the CSS you're using into a CSS file that is loaded on all pages using the static block (e.g. boxes.css)
  • Include the stylesheet used by the homepage on all pages using your static block (though this may have side effects)
  • Add the CSS to your static block inside a <style> tag (the closest option to having the CSS 'follow' the content).

You're right that it's best to avoid fiddling with Magento's core files, but you should be able to just edit your theme files, which aren't considered core code, and presumably you have done this anyway to customise the appearance.

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