


A drop-down menu combining css and js supports mainstream browsers_javascript skills
First statement:
Although I have worked in a web front-end position for many years, the technical requirements of the position are not high. HTML and CSS are mostly used, but JavaScript is rarely original and is basically copied and modified. Therefore, when I actually write it, I find that the foundation is not solid. I learn and practice at the same time, and I gain a lot.
Rendering:
No more nonsense, let’s post the code
1. css code
a:link{color:white;text-decoration:none;}
a:visited{color:white;text-decorative:none;}
a:hover{color:white;text-decorative:none;}
a:active{color:white;text-decorative:none;}
li{float:left;display:inline;background-color:#003366;width:120px;text-align:center;margin:2px;padding:10px 0 5px 0;position:relative;}
.limouseover{background-color:#0033ff;color:red;}
.limouseout{background-color:#003366;color:black;}
li ul{display:none;width:120px;position:absolute;left:0;top:30px;}
li ul li{margin:0px auto;border-top:1px solid #006699;}
2. JavaScript code
3. html code
<script>var menu1=new menu("menu1");</script>
Description:
1. Considering that ul and li pages are commonly used, you can add #menu1 before css to limit the scope of the menu style.
2. The js mainly listens for the mouse move in and removal events, and switches to the limouseover and limouseout styles accordingly; at the same time, it changes the display attribute of the submenu to achieve the display and hide function.
3. The same page can be called repeatedly without conflict. The JavaScript code in the html code is the calling instance. The previous menu1 is an arbitrary variable name, and the menu1 in the brackets is the id in the html page.
Disadvantages of this example:
1. The styles of mouseover and mouseout of menu li and submenu li are the same, that is, the same color and font, and no separate settings are implemented.
2. Since it needs to be compatible with Ie6 and ie7, while position:absolute is used, the left and top attributes are added. The top should be set according to the overall height of the menu li.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The steps to register an Ouyi account are as follows: 1. Prepare a valid email or mobile phone number and stabilize the network. 2. Visit Ouyi’s official website. 3. Enter the registration page. 4. Select email or mobile phone number to register and fill in the information. 5. Obtain and fill in the verification code. 6. Agree to the user agreement. 7. Complete registration and log in, carry out KYC and set up security measures.

The Ouyi Exchange app supports downloading of Apple mobile phones, visit the official website, click the "Apple Mobile" option, obtain and install it in the App Store, register or log in to conduct cryptocurrency trading.

To safely download the Binance APP, you need to go through the official channels: 1. Visit the Binance official website, 2. Find and click the APP download portal, 3. Choose to scan the QR code, app store, or directly download the APK file to download to ensure that the link and developer information are authentic, and enable two-factor verification to protect the security of the account.

Sesame Open Door is a platform that focuses on cryptocurrency trading. Users can obtain portals through official websites or social media to ensure that the authenticity of SSL certificates and website content is verified during access.

Choose a reliable trading platform such as OKEx to ensure access to the official entrance.

Registering a Sesame Door Account requires 7 steps: 1. Prepare a valid email or mobile phone number and a stable network; 2. Visit the official website; 3. Enter the registration page; 4. Select and fill in the registration method; 5. Obtain and fill in the verification code; 6. Agree to the user agreement; 7. Complete registration and log in, it is recommended to carry out KYC and set security measures.

Visit Binance official website and check HTTPS and green lock logos to avoid phishing websites, and official applications can also be accessed safely.

EU MiCA compliance certification, covering 50 fiat currency channels, cold storage ratio 95%, and zero security incident records. The US SEC licensed platform has convenient direct purchase of fiat currency, a ratio of 98% cold storage, institutional-level liquidity, supports large-scale OTC and custom orders, and multi-level clearing protection.
