AAA Главная
Примеры PHP Примеры JavaScript Примеры Ajax Примеры CSS,HTML

Меню на чистом CSS3 без javascript



Исходный код этого примера:

<style>
    .container {
        /*margin-left: auto;
        margin-right: auto;
        margin-top: 30px;*/
        width: 800px
    }
    #nav span {
        display: none
    }
    #nav, #nav ul {
        list-style: none outside none;
        margin: 0;
        padding: 0
    }
    #nav {
        background-color: #f5f5f5;
        border-bottom: 5px solid #333;
        float: left;
        margin-left: 1%;
        margin-right: 1%;
        position: relative;
        width: 98%
    }
    #nav ul.subs {
        background-color: #fff;
        box-shadow: 1px 1px 5px rgba(0, 0, 0, .2);
        color: #333;
        display: none;
        left: 0;
        padding: 2%;
        position: absolute;
        top: 54px;
        width: 96%
    }
    #nav > li {
        list-style: none;
        padding: 0;
        min-width: 10px;
        border-bottom: 5px solid transparent;
        float: left;
        margin-bottom: -5px;
        text-align: left;
        -moz-transition: all 300ms ease-in-out 0s;
        -ms-transition: all 300ms ease-in-out 0s;
        -o-transition: all 300ms ease-in-out 0s;
        -webkit-transition: all 300ms ease-in-out 0s;
        transition: all 300ms ease-in-out 0s
    }
    #nav li a {
        display: block;
        text-decoration: none;
        -moz-transition: color 450ms ease-in-out 0s, background-color 450ms ease-in-out 0s;
        -ms-transition: color 450ms ease-in-out 0s, background-color 450ms ease-in-out 0s;
        -o-transition: color 450ms ease-in-out 0s, background-color 450ms ease-in-out 0s;
        -webkit-transition: color 450ms ease-in-out 0s, background-color 450ms ease-in-out 0s;
        transition: color 450ms ease-in-out 0s, background-color 450ms ease-in-out 0s;
        white-space: normal
    }
    #nav > li > a {
        color: #333;
        display: block;
        font-size: 1.3em;
        line-height: 49px;
        padding: 0 15px;
        text-transform: uppercase
    }
    #nav > li:hover > a, #nav > a:hover {
        background-color: #f55856;
        color: #fff
    }
    #nav li.active > a {
        background-color: #333;
        color: #fff
    }
    #nav li:hover ul.subs {
        display: block
    }
    #nav ul.subs > li {
        display: inline-block;
        float: none;
        padding: 10px 1%;
        vertical-align: top;
        width: 33%
    }
    #nav ul.subs > li a {
        color: #777;
        line-height: 20px
    }
    #nav ul li a:hover {
        color: #f55856
    }
    #nav ul.subs > li > a {
        font-size: 1.3em;
        margin-bottom: 10px;
        text-transform: uppercase
    }
    #nav ul.subs > li li {
        float: none;
        padding-left: 8px;
        -moz-transition: padding 150ms ease-out 0s;
        -ms-transition: padding 150ms ease-out 0s;
        -o-transition: padding 150ms ease-out 0s;
        -webkit-transition: padding 150ms ease-out 0s;
        transition: padding 150ms ease-out 0s
    }
    #nav ul.subs > li li:hover {
        padding-left: 15px
    }
    @media all and (max-width: 980px) {
        #nav > li {
            float: none;
            border-bottom: 0;
            margin-bottom: 0
        }
        #nav ul.subs {
            position: relative;
            top: 0
        }
        #nav li:hover ul.subs {
            display: none
        }
        #nav li #s1:target + ul.subs, #nav li #s2:target + ul.subs {
            display: block
        }
        #nav ul.subs > li {
            display: block;
            width: auto
        }
    }
</style>

<h1>Меню на чистом CSS3 без javascript</h1>

<br class="clear">

<div class=container>
    <ul id=nav>
        <li><a href="#">Главная</a></li>
        <li><a href="#s1">Меню 1</a>
            <span id=s1></span>
            <ul class=subs>
                <li><a href="#">Заголовок a</a>
                    <ul>
                        <li><a href="#">Подменю x</a></li>
                        <li><a href="#">Подменю y</a></li>
                        <li><a href="#">Подменю z</a></li>
                    </ul>
                </li>
                <li><a href="#">Заголовок b</a>
                    <ul>
                        <li><a href="#">Подменю x</a></li>
                        <li><a href="#">Подменю y</a></li>
                        <li><a href="#">Подменю z</a></li>
                    </ul>
                </li>
            </ul>
        </li>
        <li class=active><a href="#s2">Меню 2</a>
            <span id=s2></span>
            <ul class=subs>
                <li><a href="#">Заголовок c</a>
                    <ul>
                        <li><a href="#">Подменю x</a></li>
                        <li><a href="#">Подменю y</a></li>
                        <li><a href="#">Подменю z</a></li>
                    </ul>
                </li>
                <li><a href="#">Заголовок d</a>
                    <ul>
                        <li><a href="#">Подменю x</a></li>
                        <li><a href="#">Подменю y</a></li>
                        <li><a href="#">Подменю z</a></li>
                    </ul>
                </li>
            </ul>
        </li>
        <li><a href="#">Меню 3</a></li>
    </ul>
</div>

<br class="clear">



.

© Copyright 2008-2016 by KDG