Home  >  Article  >  Web Front-end  >  How to make a css drop-down menu?

How to make a css drop-down menu?

不言
不言Original
2019-04-10 16:20:354365browse

css can achieve many effects in web pages, among which the CSS drop-down menu is an effect that is often used. This article will share with you the specific implementation method of the CSS drop-down menu.

How to make a css drop-down menu?

# Without further ado, let’s take a look at the specific implementation code.

HTML code:

<ul>
    <a href="#">水果</a>
    <ul>
        <li><a href="#">苹果</a></li>
        <li><a href="#">香蕉</a></li>
        <li><a href="#">草莓</a></li>
    </ul>
</ul>
<ul>
    <a href="#">甜点</a>
    <ul>
        <li><a href="#">蛋糕</a></li>
        <li><a href="#">曲奇</a></li>
        <li><a href="#">面包</a></li>
    </ul>
</ul>
<ul>
    <a href="#">奶茶</a>
    <ul>
        <li><a href="#">红豆奶茶</a></li>
        <li><a href="#">珍珠奶茶</a></li>
        <li><a href="#">全套奶茶</a></li>
    </ul>
</ul>

CSS code:

 *{
            padding: 0;
            margin: 0;
        }
        ul,a{
            font-size: 20px;
            list-style: none;
            text-decoration: none;
            background-color: #3C3C3C;
            color: #FFFFFF;
            width: 100px;
            text-align: center;
            border: 0px solid black;
            border-radius: 5px;
            margin-top: 1px;
        }
        a{
            display: block;
        }

        .plat{
            display: none;
        }
        .nav{
             float: left;
             margin-left: 1px;
         }
        .nav:hover .plat{
            display: block;
            clear: both;
        }
        .plat li:hover>a{
            background-color: dimgrey;
        }

The running effect is as follows: When the mouse is placed on the drop-down button, a drop-down menu will appear.

How to make a css drop-down menu?

This article has ended here. For more exciting content, you can pay attention to the CSS Video Tutorial column of the PHP Chinese website! ! !

The above is the detailed content of How to make a css drop-down menu?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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