CSS display: None

Source: Internet
Author: User

1. if it is in a style file or page file CodeDirectly use display: none to hide the elements. After loading the page, the element is not displayed by setting the style in Js, using JS Code will not be able to correctly obtain some attributes of this element, such as offsettop and offsetleft. The returned value will be 0 and the style will be set through Js. display to display the elements before obtaining these values correctly.

2. elements hidden using display: None will not be searched by Baidu or other search sites, which will affect the SEO of the website. In some cases, you can use left:-100000px to achieve the same effect.

3. If you use a style file or <style> CSS </style> to set the display: None style of an element, use js to set the style. display = "" Cannot display elements. It can be replaced by block or Inline values. This issue does not occur when you set the element directly through style = "display: none ".

4. style can be used in some cases. visibility to replace style. display, but note the style. when visibility hides an element, the space occupied by the element on the page is retained, while the style. display hides elements and allows them to occupy the 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.