I have a requirement of keeping a div hidden and make it visible when user performs an action.
But, due to dependencies on an external script, I cannot use style="display:none"
for my div.
Therefore, to meet the requirement, I am thinking of using style="visibility:hidden,height:0"
for my div and when user performs an action, make it visible using jquery by changing the style to "visibility:visible,height:auto"
which I have tested and working fine.
Is there any issue with the approach I have used when using in computers and mobiles? Whether any browser prevent content on a div which has height 0?
I have seen some posts in this forum suggesting to use of "position:absolute" along with height changes to meet this objective. So, is it needed to change the div to absolute or my approach of changing the visibility and height is fine?
display: none
? Are you able to toggle a CSS class instead of using inline styles?display:none
, you could move the element outside of the visible range (like far negative top and absolute position)