Ещё один аккордеон на CSS3

Дата: 13.01.2014
Автор: Сергей
Источник: bulatlab.ru

Доброго времени суток, дорогой читатель!

 

В сегодняшней стать, как я и обещал раньше, пойдёт речь ещё об одном аккордеонном меню, выполненном с помощью CSS. Главное отличие данного меню от рассмотренных в предыдущих статьях заключается в использовании для выбора пунктов меню (отслеживания клика) вместо псевдоклассов target и nth-of-type элемента формы -  input типа переключатель (radio).

 

Как обычно, создаётся html-страничка со следующей разметкой:

 



input id="ac-2" type="radio" name="accordion-1">
input id="ac-3" type="radio" name="accordion-1">
input id="ac-4" type="radio" name="accordion-1">

 

Как видно из приведенного кода, меню состоит из четырёх блоков div, в каждом из которых имеется элемент формы input с соответствующей ему меткой label (пункты меню), а также запись с маркированным списком из ссылок(подпункты меню).

 

Внешний вид и поведение всех элементов определяем в таблице стилей, код которой помещаем в раздел head:

 

style>
.container{ width: 250px; margin: 10px auto 30px auto;}
.container input{ display: none;}
.container ul {list-style-type:none;}
.container a{ text-decoration: none;color:#777;}
.container a:hover{ text-decoration: underline;color:#444;}

.container  label{
    font-family: 'Arial Narrow', Arial, sans-serif;
    padding: 5px 20px;
    position: relative;
    z-index: 20;
    display: block;
    height: 30px;
    cursor: pointer;
    color: #777;
    text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
    line-height: 33px;
    font-size: 19px;
    background: -moz-linear-gradient(top, #ffffff 1%, #eaeaea 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffffff), color-stop(100%,#eaeaea));
    background: -webkit-linear-gradient(top, #ffffff 1%,#eaeaea 100%);
    background: -o-linear-gradient(top, #ffffff 1%,#eaeaea 100%);
    background: -ms-linear-gradient(top, #ffffff 1%,#eaeaea 100%);
    background: linear-gradient(top, #ffffff 1%,#eaeaea 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eaeaea',GradientType=0 );
    box-shadow: 
        0px 0px 0px 1px rgba(155,155,155,0.3), 
        1px 0px 0px 0px rgba(255,255,255,0.9) inset, 
        0px 2px 2px rgba(0,0,0,0.1);
}


.container label:hover{
    box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5) inset;
    -moz-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5) inset;
    -webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5) inset;   
 
}


.container article{
    background: rgba(255, 255, 255, 0.5);
    margin-top: -1px;
    overflow: hidden;
    height: 0px;
    position: relative;
    z-index: 10;
    -webkit-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
    -moz-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
    -o-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
    -ms-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
    transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
}

.container input:checked ~ article {
     -webkit-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
    -moz-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
    -o-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
    -ms-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
    transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
    box-shadow: 0px 0px 0px 1px rgba(155,155,155,0.3);
    height: 150px;
}

В итоге получаем ещё одно простенькое симпатичное меню.

  

 

 

Оценить эту статью:   
Просмотров: 1576
Комментариев: 0
Оценка: (0)


Гости не могут добавлять комментарии, войдите или зарегистрируйтесь.
Поделитесь этой страничкой в социальных сетях