CSS dropdown menu
Use CSS to create an effect that displays a drop-down menu when the mouse is moved up.
Drop-down menu example:
When the mouse moves over the specified element, a drop-down menu will appear.
php.cn
Create a drop-down menu and allow the user to select an item in the list:
php.cn
Comments:
HTML part:
We can use any HTM element to open the drop-down menu , such as: , or a
Use a container element (such as
Use
CSS part: The
.dropdown class uses position:relative, which will set the content of the drop-down menu to be placed in the lower right corner of the drop-down button (using position:absolute). The
.dropdown-content class is the actual drop-down menu. It is hidden by default and will be displayed after the mouse moves to the specified element. Note that the min-width value is set to 160px. You can modify it as you like. Note: If you want to set the drop-down content to be consistent with the width of the drop-down button, you can set width to 100% (the overflow:auto setting can scroll on small screen sizes).
We use the box-shadow attribute to make the drop-down menu look like a "card".