How to hide an element, without it moving other elements?

2,376 views
Skip to first unread message

Pierre M

unread,
Nov 12, 2013, 2:46:50 PM11/12/13
to ang...@googlegroups.com
When I use "ng-hide" on a button, the elements to the right hand-side of the button move when the button gets hidden. 
How could I avoid these other elements moving?

Thank you
Pierre

Michael Bielski

unread,
Nov 12, 2013, 3:00:07 PM11/12/13
to ang...@googlegroups.com
ng-hide uses "display:none" which removes the element from the display calculations. You need to make a new directive that uses "visibility:hidden" which will keep the item in the display calculations.

Pierre M

unread,
Nov 12, 2013, 7:47:23 PM11/12/13
to ang...@googlegroups.com

Great, thanks a lot Micheal :) I'm surprised to not find it on ngmodules.com, it might become my first contribution.

ng-hide uses "display:none" which removes the element from the display calculations. You need to make a new directive that uses "visibility:hidden" which will keep the item in the display calculations.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/B0F945ei4sQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

matt casey

unread,
Apr 30, 2014, 10:05:05 AM4/30/14
to ang...@googlegroups.com
You could override Angular using CSS:

.ng-hide {
visibility: hidden;
display: block !important;
}

(You should namespace this, though, in case somewhere else you do want ng-hide to use display: none)
Reply all
Reply to author
Forward
0 new messages