دوره های پرنیان

کد منوی زیبای بازشونده با css3

در طول یکی از جلسات کلاسم در مجتمع فنی سعادت آباد کد منوی همبرگری با استفاده از css click و css3 برای بچه ها زدم.

در این تریک دو اتفاق می افتد. اول اینکه منو بصورت دایره وار تا انتهای صفحه باز میشود و دوم اینکه سه خط منو به ضربدر تبدیل شده و با کلیک روی همان مجدد به حالت منوی بسته تبدیل میشود.

کد منوی زیبای بازشونده با css3
کد منوی زیبای بازشونده با css3

کد سی اس اس:

[box type=”success” align=”” class=”” width=””]

<style>
*, ::before, ::after{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background-image: url(pic/1280px-Gooseberry-spring.jpg);
background-size: 100% 100%;
height: 100vh;
}
input{
display: none;
}
.circle{
width: 200px;
height: 200px;
border-radius: 50%;
background: white;
transform: translate(-100px, -100px);
transition: .4s;
}
.menu{
display: block;
width: 40px;
height: 50px;
/* background: red;*/
position: absolute;
top: 10px; left: 20px;
z-index: 9;
cursor: pointer;
transition: 2s;
}
.menu>span{
transform: translateY(24px);
}
.menu>span, .menu>span:after, .menu>span:before{
display: block;
width: 100%;
height: 2px;
background: black;
border-radius: 3px;
transition: 1s;
}
.menu>span:after{
content: ”;
transform: translateY(15px);
transform-origin: bottom right;
}
.menu>span:before{
content: ”;
transform: translateY(-15px);
transform-origin: top right;
}
#main>input[type=”checkbox”]:checked ~ .menu>span{
background: transparent;
}
#main>input[type=”checkbox”]:checked ~ .menu>span:before{
transform:translateY(-12.5px) rotate(-45deg);
}
#main>input[type=”checkbox”]:checked ~ .menu>span:after{
transform:translateY(12.5px) rotate(45deg);
}

#main>input[type=”checkbox”]:checked ~ .circle{
width: 100%;
height: 100vh;
border-radius: 0;
transform: translate(-0, -0);
}
.circle>ul{
width: 30%;
transform: translateY(100px);
display: none;
}
.circle>ul>li{
list-style-type: none;
font-size: 2.5em;
padding: 50px;
border-bottom: 1px solid black;
cursor: pointer;
}
#main>input[type=”checkbox”]:checked ~ .circle>ul{
display: block;
}
</style>

[/box]

کد html تریک فوق:

[box type=”success” align=”” class=”” width=””]

<div id=”main”>
<input type=”checkbox” id=”tick”>
<label class=”menu” for=”tick”>
<span></span>
</label>
<div class=”circle”>
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li>GALLERY</li>
</ul>
</div>
</div>

[/box]

دانلود کد فوق : کلیک کنید

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

کلاس طراحی سایت