CSS Display:none Use Note Summary _ Experience Exchange
Source: Internet
Author: User
1, if in the style file or the page file code directly with the Display:none element is hidden, loading the page, in the absence of the JS set style to make the element display, the use of JS code will not be able to correctly obtain some of the element properties, such as offsettop, Offsetleft and so on, the returned value will be 0, the value can be obtained correctly after the element is displayed by JS setting style.display.
2, the use of display:none hidden elements will not be Baidu and other search site retrieval, will affect the site's SEO, in some cases can use left:-100000px to achieve the same effect.
3, if the style file or way to set the elements of the Display:none style, with the JS set style.display= "" does not make the element display, you can use block or inline equivalent to replace. There is no problem with setting the style= "Display:none" directly on the element
4. In some cases, you can use style.visibility instead of style.display, but be aware that style.visibility hides elements while preserving the space occupied by the elements on the page, Style.display hides the elements and makes up the occupied page space.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.