简体   繁体   English

[Angular][Nebular] 主体背景与主题同步

[英][Angular][Nebular] Synchronize body background with theme

I have built a web app with angular and nebular.我用 angular 和星云构建了一个web 应用程序 The default theme I enabled is the 'cosmic' one, and I have seen that when scrolling too far up or down (in phones or with the trackpad, if you are on a laptop), you can see the white background of the body.我启用的默认主题是“宇宙”主题,我已经看到当向上或向下滚动太多时(在手机或触控板中,如果你在笔记本电脑上),你可以看到身体的白色背景。

I would like to have the body background be the same as what the theme is set to.我想让正文背景与主题设置的相同。 I have read the documentation to enable multiple themes, and that works (there is a button at the top nav to change themes dynamically), but I can't find how to get the background of the body be set according to the colors of the theme.我已阅读文档以启用多个主题,并且有效(顶部导航中有一个按钮可以动态更改主题),但我找不到如何根据 colors 的 colors主题。

I've tried doing what they suggest in here Use themes variables in my styles.scss file.我已经尝试按照他们在这里的建议使用我的styles.scss文件中的主题变量 Doing these changes in the src/app/app.component.sccs didn't set any style in the body tag, not even when using :host .src/app/app.component.sccs中进行这些更改并没有在 body 标记中设置任何样式,即使在使用:host时也是如此。

I've tried changing :host for body , and I am pretty sure I have to use the same variable they mention in the example.我尝试将:host更改为body ,我很确定我必须使用他们在示例中提到的相同变量。 But for some reason, I see it gets the values from the default theme.但由于某种原因,我看到它从默认主题中获取值。 I've tried with background-basic-color-x with x ranging from 1 to 4, and the values match with the documentation for the default theme .我已经尝试使用background-basic-color-x ,其中x的范围从 1 到 4,并且值与默认主题的文档匹配。

The term you're looking for is overscroll.您要查找的术语是过度滚动。 That is a css property and has nothing to do with nebular.那是一个 css 属性,与星云无关。 You can change the property by adding this somewhere in your css at the very top level.您可以通过在最顶层的 css 中的某处添加此属性来更改该属性。

body { overscroll-behaviour: none; }

This is actually an expected browser behaviour and it does not concern Nebular.这实际上是预期的浏览器行为,与 Nebular 无关。 If you want to test this, you can go to different websites including stackoverflow and many other and test this.如果你想测试这个,你可以 go 到不同的网站,包括 stackoverflow 和许多其他网站并测试这个。

To overcome this you've to add the above mentioned property in your body tag.为了克服这个问题,你必须在你的 body 标签中添加上面提到的属性。 Go to Inspect element and add it in the elements tab to temporarily see the property in action. Go 到 Inspect element 并将其添加到 elements 选项卡中以临时查看该属性的运行情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM