Answer the question
In order to leave comments, you need to log in
How to implement a drop down list on menu button click on small screens with just CSS?
<div class="menu-wrapper">
<div class="menu">
<div class="navi">
<div class="burger">
<hr>
<hr>
<hr>
</div>
<ul>
<li><a href="#">О компании</a></li>
<li><a href="#">Доставка</a></li>
<li><a href="#">Рассрочка</a></li>
<li><a href="#">Адреса магазинов</a></li>
<li><a href="#">Покупателю</a></li>
<li><a href="#">Отзывы</a></li>
<div class="clearfix"></div>
</ul>
</div>
<div class="social">
<a href="#"><i class="fa fa-vk fa-lg" aria-hidden="true"></i></a>
<a href="#"><i class="fa fa-facebook fa-lg" aria-hidden="true"></i></a>
<a href="#"><i class="fa fa-twitter fa-lg" aria-hidden="true"></i></a>
<a href="#"><i class="fa fa-envelope-o fa-lg" aria-hidden="true"></i></a>
</div>
<div class="clearfix"></div>
</div>
<div class="menu-mobile">
<ul>
<li><a href="#">О компании</a></li>
<li><a href="#">Доставка</a></li>
<li><a href="#">Рассрочка</a></li>
<li><a href="#">Адреса магазинов</a></li>
<li><a href="#">Покупателю</a></li>
<li><a href="#">Отзывы</a></li>
</ul>
</div>
</div>
.menu-wrapper{
font-family: 'Open Sans', sans-serif;
width: 100%;
background-color: #232323;
background-size: cover;
}
.menu{
width: 96%;
padding: 20px 2%;
max-width: 1280px;
margin: auto;
}
/*Навигация*/
.navi{
float: left;
width: 75%;
}
.burger{
display: none;
width: 30px;
cursor: pointer;
padding: 5px;
}
.burger hr{
margin: 5px 10%;
width: 80%;
color: #FE2B2B;
height: 2px;
background-color: #FE2B2B;
border: 0;
}
.navi ul li{
margin-right: 65px;
font-size: 14px;
font-weight: bold;
float: left;
}
.navi ul li a{
-webkit-transition: all 200ms ease;
-moz-transition: all 200ms ease;
-o-transition: all 200ms ease;
-ms-transition: all 200ms ease;
transition: all 200ms ease;
text-decoration: none;
color: #FFFFFF;
}
.navi ul li a:hover{
color: #FE2B2B;
}
/*Адаптивная навигация*/
.menu-mobile{
width: 96%;
padding: 10px 2%;
max-width: 1280px;
margin: auto;
display: none;
}
.menu-mobile ul{
text-align: center;
}
.menu-mobile ul li{
padding: 5px;
}
.menu-mobile ul li a{
font-weight: bold;
color: #FFFFFF;
text-decoration: none;
-webkit-transition: all 200ms ease;
-moz-transition: all 200ms ease;
-o-transition: all 200ms ease;
-ms-transition: all 200ms ease;
transition: all 200ms ease;
}
.menu-mobile ul li a:hover{
color: #FE2B2B;
}
.burger:hover .menu-mobile{
display: block;
}
/*Иконки социальных сетей*/
.social{
float: right;
width: 25%;
margin-top: -4px;
}
.social i{
color: #FFFFFF;
margin-left: 50px;
-webkit-transition: all 200ms ease;
-moz-transition: all 200ms ease;
-o-transition: all 200ms ease;
-ms-transition: all 200ms ease;
transition: all 200ms ease;
}
.social i:hover{
color: #FE2B2B;
}
.clearfix{
clear: both;
}
/*Стили для навигации*/
@media screen and (max-width:1269px){
.navi ul li{
margin-right: 60px;
}
}
@media screen and (max-width:1224px){
.navi ul li{
margin-right: 50px;
}
.social i{
margin-left: 40px;
}
}
@media screen and (max-width:1142px){
.navi ul li{
margin-right: 40px;
}
}
@media screen and (max-width:1060px){
.navi ul li{
margin-right: 30px;
}
.social i{
margin-left: 30px;
}
}
@media screen and (max-width:977px){
.navi ul li{
margin-right: 25px;
}
}
@media screen and (max-width:933px){
.navi ul li{
margin-right: 15px;
}
.social i{
margin-left: 20px;
}
}
@media screen and (max-width:870px){
.social i{
margin-left: 20px;
}
}
@media screen and (max-width:850px){
.social i{
margin-left: 15px;
}
.navi ul li{
font-size: 13px;
margin-right: 12px;
}
}
@media screen and (max-width:810px){
.social i{
margin-left: 10px;
}
.navi ul li{
margin-right: 10px;
}
}
@media screen and (max-width:790px){
.burger{
display: block;
}
.navi{
width: 60%;
}
.navi ul li{
display: none;
}
.social{
width: 40%;
}
.social i{
margin-top: 12px;
margin-left: 35px;
}
}
@media screen and (max-width:630px){
.social i{
margin-left: 25px;
}
}
@media screen and (max-width:510px){
.social i{
margin-left: 15px;
}
}
@media screen and (max-width:410px){
.navi{
width: 40%;
}
.social{
width: 60%;
}
.social i{
margin-left: 20px;
}
}
Answer the question
In order to leave comments, you need to log in
1/ It's not a button, it's a simple div, it has no focus.
2. Better to use js
A dropdown menu in pure css is done through a checkbox hack. Googled in 20 seconds) But IMHO it's much faster to write the same thing in js/jquery. There business for 5 minutes along with reading the methodology.
JavaScript. Google it, there are tons of answers to this question.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question