ng-show disturbing div layout - angularJS

橙三吉。 提交于 2019-12-08 15:41:32

问题


I am using ng-show="!notesOpened" to hide a div if the notesOpened variable is true. 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? so that all div elements around the div being hidden stay in the same place


回答1:


ng-hide uses the same property that you're referring to, i.e. display: none.

If you need to achieve this, you need to use visibility: hidden;

For that you can use the ng-class attribute.

eg: ng-class="{'vis-hidden': notesOpened==true}"

  .vis-hidden{
     visibility: hidden;
  }



回答2:


I have got this working

ng-style="{visibility: notesOpened && 'visible' || 'hidden'}"




回答3:


You should try ng-class instead so you can give the div a class which only do display:none



来源:https://stackoverflow.com/questions/23060869/ng-show-disturbing-div-layout-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!