如何仅对一个组件禁用身体样式 [英] how can i disable a body style for only one component
本文介绍了如何仅对一个组件禁用身体样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想对一个组件禁用overflow-y: hidden
样式.这种风格就是我的style.scss这样的
I want to disable overflow-y: hidden
style for only one component. This style is in my style.scss like so
body {
overflow-y: hidden;
}
我在组件中尝试了此操作,但是没有用.
I tried this in my component but it did not work.
<div class="div1" style="overflow-y: visible !important;">
...
</div>
推荐答案
可以尝试放
.visibleClass{overflow-y: visible ;}
转到正文CSS属性下的style.css
to style.css under body css attribute
将激活事件添加到router-outlet
<router-outlet (activate)="showHideNav($event)"></router-outlet>
然后在component.ts中
then in component.ts
showHideNav(event){
event instanceof YourComponent ? document.body.classList.add("visibleClass") :
document.body.classList.remove("visibleClass")
}
这篇关于如何仅对一个组件禁用身体样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文