Home > Web Front-end > JS Tutorial > body text

Using js attributes to achieve the effect of horizontal drop-down menu in html5 (code)

不言
Release: 2018-08-13 16:17:13
Original
1913 people have browsed it

The content of this article is about the effect of using js attributes to achieve horizontal drop-down menus in HTML5. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

<!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style>
    *{padding:0px;}
    p{margin:20px 150px;}
    ul{list-style:none;}
    ul li{float:left;position:relative;}
    ul li a{text-decoration:none;
            background:#900;
            height:40px;
            display:block;
            color:#fff;
            font-weight:bold;
            line-height:40px;
            text-align:center;
            margin-right:1px;
            padding:0px 15px;
    }
    ul li a:hover{background:#f90;}
    ul li ul li{float:none;}
    ul li ul{position:absolute;top:41px;left:0px;
            display:none;
    }
</style>
<script>
    function showmenu(li){
    var submenu=li.getElementsByTagName("ul")[0];
    submenu.style.display="block";
    }
    function hidemenu(op){
    var submenu=op.getElementsByTagName("ul")[0];
    submenu.style.display="none";
    }
</script>
</head>
<body>
    <p>
    <ul>
        <li><a href="#">学校简介</a></li>
        <li onmouseover="showmenu(this)" onmouseleave="hidemenu(this)"><a href="#">管理机构</a></li>
        <li onmouseover="showmenu(this)" onmouseleave="hidemenu(this)"><a href="#">学院设置</a>
        <ul>
            <li><a href="#">电气学院</a></li>
            <li><a href="#">材料学院</a></li>
            <li><a href="#">测绘学院</a></li>
            <li><a href="#">安全学院</a></li>
            <li><a href="#">体育学院</a></li>
            <li><a href="#">化工学院</a></li>
        </ul>
        </li>
        <li onmouseover="showmenu(this)" onmouseleave="hidemenu(this)"><a href="#">科学研究</a>
            <ul>
            <li ><a href="#">科研机构</a></li>
            <li ><a href="#">科研平台</a></li>
            <li ><a href="#">科研论文</a></li>
            <li ><a href="#">成果转化</a></li>
            </ul>
        </li>
        <li onmouseover="showmenu(this)" onmouseleave="hidemenu(this)"><a href="#">招生就业</a>
            <ul>
            <li ><a href="#">本科生招生</a></li>
            <li ><a href="#">硕士生招生</a></li>
            <li ><a href="#">博士生招生</a></li>
            <li ><a href="#">就业信息</a></li>
            </ul>
        </li>
        <li><a href="#">呼唤英才</a></li>
    </ul>
    </p>
</body>
</html>
Copy after login

Related recommendations:

js implements a search function similar to Lenovo keywords (with code)

js encapsulates the _new function and the method of implementing the new keyword (with code test)

Introduction to the basic syntax of js: data types and variable types

The above is the detailed content of Using js attributes to achieve the effect of horizontal drop-down menu in html5 (code). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!