CSS on the use of Display:none to share

Source: Internet
Author: User
The Web page foreground code often uses the Display:none style, usually found several characteristics need to notice

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 the <style>css</style> way to set the Display:none style of elements, with JS set style.display= "" does not make the element display, You can use block or inline equivalents instead. 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.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.