Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
display: none - you can't smoothly show with one css, unlike left.
This trick was originally intended for screen readers. They do not see the text hidden through display: none, but read it without any problems if it is shifted off the screen.
It is still not customary in our country to pay attention to the accessibility of the site to the blind and other disabled people, but in the West it is almost mandatory.
If display:none, background-image and other images will not be loaded until the element is visible.
Why do you think it's better, and if it's really better, why do most developers use display:none?
I was wrong, today I encountered an interesting feature of the firefox browser (it does not appear on others): In the hidden display: none block, the MatchMedia function returns null, for a block with left: -999999 everything is fine. In particular, I implemented a project where a YouTube video was supposed to be launched after pressing a button and a previously invisible block appeared on the screen. In firefox, in the invisible block, the initialization of the object with the video does not occur and instead of it there is only a black screen (everything is ok in other browsers). Rewriting the styles from display:none to left:-99999 solved the problem. Also similar is described here stackoverflow.com/questions/12056313/matchmedia-re..., therefore, in rare cases, a hack with left has the right to be, but only in rare cases.
left is useful when an element needs to have multiple positions depending on something (original idea, window size, etc.)
When using display:none in fluid layout, it will be more difficult to get the size of hidden images through js.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question