Home  >  Article  >  Web Front-end  >  CSS3 implementation of horizontal scrolling menu button sample code sharing

CSS3 implementation of horizontal scrolling menu button sample code sharing

黄舟
黄舟Original
2017-04-24 09:26:161616browse

Today I would like to share with you the implementation of a beautiful horizontal scrolling menu based on css3 Button , it is very good and has reference value. Friends who need it can refer to it

Without further ado, let’s go directly Picture:

Then the code:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>精美横向滚动菜单按钮 - Glunefish</title>
    </head>
<!-- 这里接下面的行间样式 -->
    <body>
        <ul>
            <li><a href="" class="a1"><span>Home</span></a></li>
            <li><a href="" class="a2"><span>Chat</span></a></li>
            <li><a href="" class="a3"><span>About</span></a></li>
        </ul>
    </body>
</html>

CSS:

 <style>
        ul{list-style:none;}
        ul li a{
            display:block;
            width:40px;
            height:40px; 
            background:rgb(208,165,37); 
            margin-top:10px; 
            text-decoration:none; 
            line-height:40px; 
            position:relative;
            }
        ul li a span{
            width:0; 
            height:40px;
            display:block;
            visibility:hidden;
            overflow:hidden;
            font-weight:bold;
            position:absolute;
            left:40px;
            transition:all 0.3s;
            }
        ul li .a1 span{background:rgb(30,139,180);}
        ul li .a2 span{background:rgb(125,163,23);}
        ul li .a3 span{background:rgb(175,30,131);}
        ul li a:hover span{visibility:visible; width:auto; padding:0 20px;}
    </style>

The code has been specially optimized for ease of reading, mainly involving:

CSS3 animation (transtion)

Element hiding (overflow / visibility)

The above is the detailed content of CSS3 implementation of horizontal scrolling menu button sample code sharing. 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