[英]ng-show disturbing div layout - angularJS
I am using ng-show="!notesOpened"
to hide a div if the notesOpened variable is true. 如果notesOpened变量为true,我正在使用ng-show="!notesOpened"
来隐藏div。 However when hidden it messes up layout. 然而,当它隐藏它会弄乱布局。 Is there a way to make ng-show act in the same way as the css property visibility:hidden
? 有没有办法让ng-show以与css属性visibility:hidden
相同的方式行动visibility:hidden
? so that all div elements around the div being hidden stay in the same place 以便隐藏div周围的所有div元素保持在同一个地方
ng-hide
uses the same property that you're referring to, ie display: none
. ng-hide
使用您所指的相同属性,即display: none
。
If you need to achieve this, you need to use visibility: hidden;
如果你需要实现这一点,你需要使用visibility: hidden;
For that you can use the ng-class
attribute. 为此,您可以使用ng-class
属性。
eg: ng-class="{'vis-hidden': notesOpened==true}"
例如: ng-class="{'vis-hidden': notesOpened==true}"
.vis-hidden{
visibility: hidden;
}
I have got this working 我有这个工作
ng-style="{visibility: notesOpened && 'visible' || 'hidden'}" ng-style =“{visibility:notesOpened &&'visible'||'hidden'}”
你应该尝试使用ng-class
这样你就可以给div一个只display:none
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.