CSS 下拉菜单

PHP中文网
Release: 2017-03-20 11:44:17
Original
4427 people have browsed it

使用 CSS 可以创建一个鼠标移入后显示下拉菜单的效果。

1、下拉菜单的实现

  当鼠标移入指定元素时,显示下拉菜单。代码如下:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>简单的下拉菜单</title>
<style>
.dropdown{
    position:relative;
    display:inline-block;
}

.dropdown-content{
    min-width:200px;
    border:1px solid black;
    position:absolute;
    display:none;
}

.dropdown:hover .dropdown-content{
    display:block;
}
</style>
</head>
<body>
<p class="dropdown">
    <span>鼠标你过来,我为你展示下拉菜单。</span>
    <p class="dropdown-content">
        <p>下拉菜单 1</p>
        <p>下拉菜单 2</p>
    </p>
</p>
</body>
</html>
Copy after login

  实例解析:

  HTML 部分:

    可以使用任何 HTML 元素来打开下拉菜单,比如 ,或

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!