Как я могу использовать слайд-анимацию в столбце сетки? - PullRequest
0 голосов
/ 28 февраля 2020

Интерфейс приложения:

enter image description here

Я хочу входить и выходить из меню боковой панели. Я мог закрыть меню и открыть меню с помощью значка, но не смог добавить анимацию слайда. Если кто-то имеет какие-либо ресурсы или может исправить мой код, это было бы весьма заметно. Спасибо.

https://codepen.io/WOLFION/pen/LYVyOzX

function menuClose(){
    document.getElementById('wrapper').style.gridTemplateColumns = "0   1fr";
}

function openMenu(){
    document.getElementById('wrapper').style.gridTemplateColumns = "1fr   3fr";
    document.getElementById('wrapper').style.animation = "collapse";
}
* {
    margin: 0;
    padding: 0;
}

body {
    color: #131313;
    line-height: 32px;
    box-sizing: border-box;
    font-family: 'Roboto' ;
    text-rendering: optimizeLegibility;
}

.wrapper {
    display: grid;
    grid-template-columns: 1fr  3fr;
    grid-template-rows: 1fr;
    height: 100vh;
}

/* ==================================== Hamburger Menu ============================================= */

.menu-close-icon {
    color: white;
    font-size: 44px;
}

.menu-open-icon {
    color: white;
    font-size: 44px;
}

.menu{
    position: relative;
}

.menu-close {
    /* display: flex;
    justify-content: end;
    margin-left: 200px;
    padding: 20px; */

    position: absolute;
    padding: 20px;
    right: 10px;
}

.details{
    position: relative;
}

.menu-open {
    /* display: flex;
    justify-content: end;
    margin-left: 200px;
    padding: 20px; */

    position: absolute;
    padding: 20px;
    top: 0px;
    left: 10px;
}

#wrapper{
    animation: collapse 2s forwards;
}

@keyframes collapse {
    
    0%{
        grid-template-columns: 0    1fr;
    }

    100%{
        grid-template-columns: 1fr    3fr;
    }
}


/* ================================= Menu ================================================== */

.menu {
    background-color: rgb(36, 36, 36);
    
}

.menu-items{
    display: flex;
    justify-content: center;
    align-items: center;
}

.menu-items li {
    list-style: none;
    font-size: 32px;
    padding-top: 60px;
}

.menu-heading{
    display: flex;
    justify-content: center;
    padding: 40px;
    color: white;
    font-size: 32px;
    margin-top: 80px;
}

.menu-items a{
    text-decoration: none;
    color: azure;
    transition: color 0.2s;
}
.menu-items a:hover{
    text-decoration: none;
    color: rgb(94, 94, 94);
}

.menu-heading h1::first-letter{
    background-color: rgb(0, 89, 255);
}




/* ===================================================== Details ==================================== */

.details {
    background-color: rgb(58, 58, 58);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.employee-list-page-heading h1{
    padding-top: 30px;
    color: azure;
}

.employee-name{
    display: flex;
    justify-content: center;
    padding: 30px;
    font-size: 24px;
    color: azure;
}

.employee-pic{
    display: flex;
    justify-content: center;
}

.employee-pic img{
    padding: 0   0   20px    0;
    height: 200px;
    width: auto;
}


/* ============================================== emp data ==================================================== */

.emp-data{
    display: flex;
    justify-content: center;
}

.box{
    width: 200px;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: 50px;
}

.emp-data-sub-heading{
    color: azure;
    font-size: 24px;
}

.emp-data-sub-heading-para{
    color: brown;
    padding: 20px;
    font-weight: 300;
    font-size: 38px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Attendance Management System</title>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/js/all.min.js"></script>
    <script src="/Resources/js/script.js"></script>
    <link rel="stylesheet" href="/Resources/css/style.css">
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900&display=swap" rel="stylesheet">
</head>
<body>
    <div class="container">
        <div class="wrapper" id="wrapper">
            <div class="menu"   id="menu">
                <div class="menu-close">
                    <a href="#" class="menu-close-icon">
                            <i class="fas fa-times" onclick="menuClose()"></i>
                    </a>
                </div>
                <div class="menu-heading"><h1>MENU</h1></div>
                <div class="menu-items">
                    <ul>
                        <a href="">
                            <li id="first-child">HOME</li>
                        </a>
                        <a href="">
                            <li>Students</li>
                        </a>
                        <a href="">
                            <li>Attendance</li>
                        </a>
                        <a href="">
                            <li>Records</li>
                        </a>
                        <a href="">
                            <li>Leave</li>
                        </a>
                    </ul>
                </div>
            </div>
            <div class="details"    id="details">
                <div class="menu-open">
                    <a href="#" class="menu-open-icon">
                            <i class="fas fa-times" onclick="openMenu()"></i>
                    </a>
                </div>
                <div class="employee-pic">
                    <img src="./Resources/img/Atul.png" alt="">
                </div>
                <div class="employee-name">
                    <h1>ATUL</h1>
                </div>

                <div class="emp-data">
                    <div class="attendance  emp-data-sub-heading  box">
                        <h3>Attendance</h3>
                        <p  class="emp-data-sub-heading-para">28/31</p>
                    </div>
                    <div class="Leaves  emp-data-sub-heading  box">
                        <h3>Leaves</h3>
                        <p  class="emp-data-sub-heading-para">4</p>
                    </div>
                    <div class="Leaves-Left emp-data-sub-heading box">
                        <h3>Leaves Left</h3>
                        <p  class="emp-data-sub-heading-para">2</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...