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.