In the Web development, the foreground HTML often need to control the hidden and display of elements, we most commonly is the level two navigation bar (through the movement of the mouse to trigger the Onmouseover,onmouseout event to achieve level two menu display and hide) level two menu display and hide.
However, there are two ways to influence and display the control element:
1. Display: Set how and whether an element is displayed
2. Visibility: Set element is visible or invisible
Example:
Result:
Summary:Display and visibility can also be used to hide and display elements, except that the visibility property does not hide HTML elements, but whose elements (even hidden states) are in the same place, while the display property operations HTML elements do not want to , the Display property operates on the type of the element Inline,block,none these attributes are directly related to the size and existence of the element.
Used about display and visibility have encountered:
Write the level two navigation bar menu, when using display to achieve the two level of menu and hide, the results found that the first access or refresh after the first visit, the mouse moved to a level menu two sub-menu feel like to refresh the same, with visibility implementation will not appear like this problem.
HTML element Display and hide