본문 바로가기

개발과제

[노말틱 모의 해킹 취업반 추가 개발과제 ] css - 로그인 페이지

안녕하세요! 이번에는 제 로그인 페이지를 좀 꾸미려고 합니다.

 

css파일을 이용할 거구요

 

css 관련 기본 문법은

https://developer.mozilla.org/ko/docs/Learn/Getting_started_with_the_web/CSS_basics

 

CSS 기초 - Web 개발 학습하기 | MDN

CSS (Cascading Style Sheets)는 웹페이지를 꾸미려고 작성하는 코드입니다. CSS 기초 에서 여러분이 처음 시작하며 필요한 내용을 익히도록 도와드립니다. 저희는 다음과 같은 질문에 관한 답을 드리겠

developer.mozilla.org

여기서 참고했습니다!

 

 

시작하겠습니다.

.

.

.

.

일단 링크구문을 추가하겠습니다

 

    <head>
        <meta charset="utf-8">
        <title>HAPPY HACKING!</title>
        <link rel="stylesheet" href = "style.css">
    </head>

 

head 구문에 한 줄 추가했어요

 

그리고 난 뒤에 각각 div로 나누어줬습니다.

 

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>HAPPY HACKING!</title>
        <link rel="stylesheet" href = "/css/style.css">
    </head>
    <body>
        <h1>Login</h1>
        <form action="process_login.php" method="POST">
            <div> 
                <p><input type="text" name="id" placeholder="ID입력"></p>
            </div>

            <div>
                <p><input type="password" name="pw" placeholder="PW입력"></p>
            </div>

            <div>
                <p><input type="submit" value="로그인하기"></p>
            </div>

        </form>

        <form action="join.php">
            <div>
                <p><input type="submit" value="회원가입"></p>
            </div>
        </form>

        <form action="inquiry_board.php"> 
            <div>
                <p><input type="submit" value="문의게시판"></p>
            </div>
        </form>
        
        <footer>
            <p>
            <?php session_start();
                    if (isset($_SESSION['login_error'])) {
                        echo $_SESSION['login_error'];
                        unset($_SESSION['login_error']);
                    }
            ?>
            </p>
        </footer>

    </body>
</html>

 

이렇게요

 

footer은 맨 하단에 고정을 하는 겁니다!

 

그다음에 먼저 ID 입력이랑 PW 입력을 꾸미겠습니다.

 

각각 div에 class 명을 form-group으로 하겠습니다. 그리고 전체적으로 중앙에 위치하게 하겠습니다.

 

 

-php문

 

        <form action="process_login.php" method="POST">
            <div class = "form-group"> 
                <p><input type="text" name="id" placeholder="ID입력"></p>
            </div>

            <div class = "form-group">
                <p><input type="password" name="pw" placeholder="PW입력"></p>
            </div>

            <div class = "login-button">
                <p><input type="submit" value="로그인하기"></p>
            </div>

        </form>

 

 

-css문

 

body{
    background-color:#f5f6f7;   
}

.form-group{
    width:350px;
    margin-left:auto;
    margin-right:auto;
}

.login-button{
    text-align:center;
}

 

 

한번 실행해 보겠습니다

 

음..

 

일단 진행하죠!

 

나머지 버튼들도 가우데로 위치하게 하겠습니다!

 

 

-php

 

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>HAPPY HACKING!</title>
        <link rel="stylesheet" href = "/css/style.css">
    </head>
    <body>
        <h1>Login</h1>
        <form action="process_login.php" method="POST">
            <div class = "form-group"> 
                <p><input type="text" name="id" placeholder="ID입력"></p>
            </div>

            <div class = "form-group">
                <p><input type="password" name="pw" placeholder="PW입력"></p>
            </div>

            <div class = "login-button">
                <p><input type="submit" value="로그인하기"></p>
            </div>

        </form>

        <form action="join.php">
            <div class = "join-button">
                <p><input type="submit" value="회원가입"></p>
            </div>
        </form>

        <form action="inquiry_board.php"> 
            <div class = "inquiry-button">
                <p><input type="submit" value="문의게시판"></p>
            </div>
        </form>
        
        <footer class="footer">
            <p>
            <?php session_start();
                    if (isset($_SESSION['login_error'])) {
                        echo $_SESSION['login_error'];
                        unset($_SESSION['login_error']);
                    }
            ?>
            </p>
        </footer>

    </body>
</html>

 

-css

body{
    background-color:#f5f6f7;   
}

.form-group{
    width:350px;
    margin-left:auto;
    margin-right:auto;
}

.login-button{
    text-align:center;
}

.join-button{
    display:flex;
    flex-direction:row;
    justify-content:center;
}

.inquiry-button{
    display:flex;
    flex-direction:row;
    justify-content:center;
}

.footer{
    margin:0 auto;
    text-align:center;
    bottom:5px;
    color:gray;
}

 

 

이제 각 버튼에 btn-primary1,2,3 이름을 붙이고 제가 최대한 꾸며보도록 하겠습니다.

 

 

 

 

 

 

 

-php

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>HAPPY HACKING!</title>
        <link rel="stylesheet" href = "/css/style.css">
    </head>
    <body>
        <h1>Login</h1>
        <form action="process_login.php" method="POST">
            <div class = "form-group"> 
                <input type="text" name="id" class = "form-group" placeholder="ID입력">
            </div>

            <div class = "form-group">
                <p><input type="password" name="pw" class = "form-group" placeholder="PW입력"></p>
            </div>
            <br>
            <div class = "login-button">
                <p><input type="submit" value="로그인하기" class = "btn-primary"></p>
            </div>

        </form>

        <div class="btn-btn">
            <form action="join.php">
                <div class = "join-button">
                    <p><input type="submit" value="회원가입" class = "btn-primary2"><p>
                </div>
            </form>
            <p>|</p>
            <form action="inquiry_board.php"> 
                <div class = "inquiry-button">
                    <p><input type="submit" value="문의게시판" class = "btn-primary3"></p>
                </div>
            </form>
        </div>
        
        <footer class="footer">
            <p>
            <?php session_start();
                    if (isset($_SESSION['login_error'])) {
                        echo $_SESSION['login_error'];
                        unset($_SESSION['login_error']);
                    }
            ?>
            </p>
        </footer>

    </body>
</html>

 

 

-style.css

 

body{
    background-color:#f5f6f7;   
}

h1 {
    text-align: center;
    padding: 10px 10px;
    padding-bottom: 30px;
    border-bottom:1px solid #848484;
}

.form-group{
    width: 335px;
    height: 30px;
    margin-left:auto;
    margin-right:auto;
}

.login-button{
    text-align:center;
}

.btn-primary{
    border:1px solid #03c75b;
    background-color: #03c75b;
    width:350px;
    height: 50px;
    font-size:120%;
    color: white;
    margin-left:auto;
    margin-right:auto;
    Cursor:pointer;
}

.btn-primary2{ 
    border: none;
    background-color:#f5f6f7;
    color : gray;
    height: 50px;
    font-size:120%;
    margin-left:auto;
    margin-right:2px;
    Cursor:pointer;
    position: absolute; /*자식요소 부모위치에서만 움직일 수 있다.*/
    transform: translate(-110%,-50%);
    top: 50%;
    left: 50%;
}

.btn-primary3{
    border: none;
    background-color:#f5f6f7;
    color : gray;
    height: 50px;
    font-size:120%;
    margin-left:2px;
    margin-right:auto;
    Cursor:pointer; /*버튼 위로가면 커서가 변한다*/
    position: absolute;  /*자식요소 부모위치에서만 움직일 수 있다.*/
    transform: translate(5%,-50%); /*자신의 크기 기준으로 움직인다*/
    top: 50%; /*top으로 50%만큼 움직인다*/
    left: 50%; /*left에서 50%만큼 움직인다*/
}

.btn-btn {
    width: 350px;
    display: flex;
    justify-content:space-around;
    margin: 10px auto;
    align-items: center;
    position: relative; /*자식 요소 위치 세세하게 설정용(부모)*/
}

.btn-btn>p {
    font-size: 25px;
    color : gray;
}

.join-button{
    display:flex;
    flex-direction:row;
    justify-content:center;
    Cursor:pointer;
}

.inquiry-button{
    display:flex; /*자신의 크기 안에 자식을 넣는다*/
    flex-direction:row; /*자식 나열할때 아래로 나열*/
    justify-content:center; /*가로 중앙 정렬*/
    Cursor:pointer;
}

.footer{
    margin:0 auto;
    text-align:center;
    bottom:5px;
    color:gray;
}

 

 

각각 주석처리로 설명해 드렸습니다! 한 번 실행해 보겠습니다.

 

이정도면 깔끔하죠.. 그쵸?..

 

이렇게 만들었습니다

 

오늘은 로그인 페이지 css로 꾸며봤습니다. 간단하게요

 

이제 차차 계속 한 페이지 한페이지 꾸미겠습니다!