Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DOM-Elements are there but not visible, until some CSS property is changed

I am creating a complex prototype for a Webapp (I am using Cordova to deploy it to my iPhone), and I am having the following problem:

DOM-Elements (which are not created using JavaScript but are right there in the static HTML-File) are there (they show up in the right size in the inspector) but are not visible. Sometime they are simply not being displayed, sometimes they are partly displayed, sometimes parts of them are shown at a different location. The inspector shows their "bodies" always on the right position.

There is a strange solution: As soon as an CSS property is changed after loading the side (for example unchecking and checking any property of any element in the inspector – sometimes changing a property programmatically also works) they are show correctly. The problem is occurring both in Safari and Chrome but not in Firefox (maybe a Webkit problem?). It’s worst in Safari Mobile (which is were I need it to work the most).

Using the transform: translate3d(0); hack helped at first, but doesn’t anymore – I am using and animating lots of Flexbox-elements. I am a simply asking to much from the browser?

Edit: The problem seems to occur only after I have scrolled in one container. After I have scrolled certain (completely unrelated) elements disappear.

like image 772
chl Avatar asked Jun 24 '15 12:06

chl


People also ask

Which of the following CSS properties can be used for hiding an element in the DOM without changing the layout of the page?

The visibility CSS property shows or hides an element without changing the layout of a document.

Can the DOM change CSS?

With JavaScript, we are able to set CSS styles for one or multiple elements in the DOM, modify them, remove them or even change the whole stylesheet for all your page.

Does visibility remove from DOM?

display:none; will remove the DOM elements visual style / physical space from the DOM, whereas visibility:hidden; will not remove the element, but simply hide it.


1 Answers

Try one of the following to your animated element.

transform: translatez(0)

or

backface-visibility: hidden;

or

will-change: transform;
like image 133
Naren Srinivasan S Avatar answered Oct 03 '22 03:10

Naren Srinivasan S