Sproutcore 自定义 CSS
嘿,所以我尝试将一些自定义 CSS 应用到 SproutCore 中的 ToolbarView 。我已经设法通过将CSSE文件保存在layouts/english.lproj中来加载它,但是我编写的样式被SproutCore提供的样式覆盖。这只发生在框架提供的样式上。就我而言,这将是背景图像元素。如果我在 Chrome 的开发人员工具(如下)中查看该页面,您可以看到两种样式都已应用,但因为我的样式表随后加载,所以它被覆盖。如果我取消选中 Chrome 中的背景图像元素,我的背景就可以看到。
以下是我尝试过的事情:
- 为我的工具栏提供一个额外的 CSS 类,并以该类为目标(在我的例子中为 AppToolbar)
- 以每个 CSS 类为目标,包括 app-toolbar (
.sc-view.sc-toolbar-view.AppToolbar< /code>)
- CSS
!important
- 大量谷歌搜索和阅读文档
还有其他人遇到过这个问题吗?任何帮助/建议将不胜感激。
已发布屏幕截图
Hey, so I'm trying to apply some custom css to a ToolbarView in SproutCore. I've managed to get a CSSE file loading by saving it in layouts/english.lproj but the styles I write are being overridden by the ones provided by SproutCore. This only happens for styles provided by the framework. In my case this would be the background-image element. If I view the page in Chrome's developer tools (below) you can see that both styles are being applied but because my stylesheet loads afterwards it is overridden. If I uncheck the background-image element in Chrome, my background can be seen.
Here are the things that I have tried:
- Giving my Toolbar an extra CSS class and targeting that (in my case AppToolbar)
- Targeting every CSS class including app-toolbar (
.sc-view.sc-toolbar-view.AppToolbar
) - CSS
!important
- Lots of Googling and Reading Documentation
Has anyone else had this problem? any help/suggestions would be greatly appreciated.
Screenshot posted here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用背景属性而不是背景图像属性。
Try using the background property instead of the background-image property.
一个快速的解决方案是为您的 mainPane 指定一个名为“myApp”的 LayerId,并在所有 css 属性前加上“#myApp”作为前缀:
更干净的解决方案是为您的应用程序提供一个主题: http://guides.sproutcore.com/theming_app.html 。
之后,你必须在你的 css 类前面加上 $theme:
不要忘记您可以使用集成到 Sproutcore 的 scss。这样你就可以像这样封装所有规则:
这允许你只编写一次 $theme (每个文件),并且所有 css 规则将优先于 SC 提供的规则。
A quick solution is to give your mainPane a layerId of "myApp" and prefix all your css properties with "#myApp":
A cleaner solution is to give to your app a theme: http://guides.sproutcore.com/theming_app.html.
After that, you will have to prefix your css class with $theme:
Don't forget that you can use scss which is integrate to Sproutcore. This way you can encapsulate all your rules like this:
This allow you to write $theme only once (per file) and all your css rules will have priority over the one provided by SC.