์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

[์›น ํ•ดํ‚น/ 1์ฃผ์ฐจ] <HTML, CSS, JavaScript> - ๋กœ๊ทธ์ธ, ํšŒ์›๊ฐ€์ž… ํŽ˜์ด์ง€ ๊ตฌํ˜„

Ping!

by _young 2024. 8. 18. 23:52

๋ณธ๋ฌธ

 

๐Ÿ“บ ์‹œ์—ฐ ์˜์ƒ

๋™์˜์ƒ ์„œ๋น„์Šค๊ฐ€ ์ข…๋ฃŒ๋˜์–ด ํ•ด๋‹น ์ฝ˜ํ…์ธ ๋ฅผ ์žฌ์ƒํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

 

์˜์ƒ ๊ฐ„๋‹จ ์š”์•ฝ

1. ๋น„ํšŒ์›์ผ ์‹œ ํšŒ์›๊ฐ€์ž… ํŽ˜์ด์ง€๋กœ ์ด๋™

2. ์ •๋ณด ์ž…๋ ฅ ์ค‘ ๋ฆฌ์…‹ ๊ฐ€๋Šฅ

3. ํ•„์ˆ˜ ์ •๋ณด ๋ฏธ์ž…๋ ฅ ์‹œ ํšŒ์›๊ฐ€์ž… ๋ถˆ๊ฐ€

4. ๊ด€์‹ฌ ๋ถ„์•ผ๋Š” ๋ณต์ˆ˜ ์„ ํƒ ๊ฐ€๋Šฅ โžก๏ธ <input type="checkbox">

5. ์„ฑ๋ณ„์€ ๋‹จ์ผ ์„ ํƒ ๊ฐ€๋Šฅ โžก๏ธ <input type="radio">

6. ํ•„์ˆ˜ ์ •๋ณด ๋ชจ๋‘ ์ž…๋ ฅ ์‹œ ํšŒ์›๊ฐ€์ž… ์„ฑ๊ณต ์•Œ๋ฆผ ๋œจ๋ฉฐ ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€๋กœ ์ด๋™

7. ์•„์ด๋””, ํŒจ์Šค์›Œ๋“œ ์ •๋ณด ์ž…๋ ฅ ํ›„ ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ๋ˆ„๋ฅด๋ฉด welcome ํŽ˜์ด์ง€๋กœ ์ด๋™

 

 

 

๊ณ„์† ์ˆ˜์ •์ค‘์ด๋ผ ์ฃผ์„์ด ๋งŽ์€ ์  ์ฃผ์˜,,

login.html (๋กœ๊ทธ์ธ ํŽ˜์ด์ง€)

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>๋กœ๊ทธ์ธ ํŽ˜์ด์ง€</title>
    <link rel="stylesheet" href="login.css">
</head>
<body>
    <div class="container">
        <div class="image-container">
            <img src="login.png" alt="๋กœ๊ทธ์ธ ์ด๋ฏธ์ง€">
        </div>
        <div class="login-container">
            <h2>๋กœ๊ทธ์ธ</h2>
            <form action="welcome.html" method="post">
                <input type="text" name="username" placeholder="์•„์ด๋””" required>
                <input type="password" name="password" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ" required>
                <button type="submit">๋กœ๊ทธ์ธ</button>
            </form>
            <p class="signup-link">ํšŒ์›์ด ์•„๋‹ˆ์‹ ๊ฐ€์š”? <a href="register.html">ํšŒ์›๊ฐ€์ž…</a></p>
        </div>
    </div>
</body>
</html>

 

login.css (๋กœ๊ทธ์ธ ํŽ˜์ด์ง€ ์Šคํƒ€์ผ)

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    /* height: 100vh;
    background-color: #f0f0f0; */
    margin: 0; /* ์ถ”๊ฐ€ */
}

.container {
    display: flex; /* ์ถ”๊ฐ€: Flexbox๋กœ ์ขŒ์šฐ ๋ฐฐ์น˜ */
    width: 80%;
    height: 80vh;
    max-width: 1200px;
    margin: auto;
    /* background-color: white;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); */
}

.image-container {
    flex: 1; /* ์ˆ˜์ •: width ๋Œ€์‹  flex ์‚ฌ์šฉ */
    display: flex; /* ์ถ”๊ฐ€: ์ค‘์•™ ์ •๋ ฌ์„ ์œ„ํ•œ flexbox */
    justify-content: center; /* ์ถ”๊ฐ€: ์ด๋ฏธ์ง€ ์ค‘์•™ ์ •๋ ฌ */
    align-items: center; /* ์ถ”๊ฐ€: ์ด๋ฏธ์ง€ ์ค‘์•™ ์ •๋ ฌ */
    padding: 20px; /* ์ถ”๊ฐ€: ์ด๋ฏธ์ง€ ์ฃผ๋ณ€ ํŒจ๋”ฉ */
}

.image-container img {
    width: 100%; /* ์ˆ˜์ •: ๊ฐ€๋กœ ์ „์ฒด๋ฅผ ์ฑ„์šฐ๋„๋ก ์„ค์ • */
    height: auto; /* ์ˆ˜์ •: ๋†’์ด ๋น„์œจ ์ž๋™ ์กฐ์ • */
    max-height: 100%; /* ์ถ”๊ฐ€: ๋†’์ด๋ฅผ ๋ถ€๋ชจ ์ปจํ…Œ์ด๋„ˆ์— ๋งž์ถค */
    object-fit: contain; /* ์ˆ˜์ •: ์ด๋ฏธ์ง€ ๋น„์œจ ์œ ์ง€ ๋ฐ ํฌ๊ธฐ ์กฐ์ • */
}

.login-container {
    flex: 1; /* ์ˆ˜์ •: width ๋Œ€์‹  flex ์‚ฌ์šฉ */
    display: flex;
    flex-direction: column;
    justify-content: center; /* ์ˆ˜์ •: ์„ธ๋กœ ๊ฐ€์šด๋ฐ ์ •๋ ฌ */
    padding: 20px 40px; /* ์ˆ˜์ •: padding ์กฐ์ • */
}

.login-container h2 {
    margin-bottom: 20px;
    font-size: 24px;
    text-align: center;
}

.login-container form {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-container input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
}

.login-container button {
    width: 100%;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.login-container button:hover {
    background-color: #45a049;
}

.signup-link {
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
}

.signup-link a {
    color: #007BFF;
    text-decoration: none;
}

.signup-link a:hover {
    text-decoration: underline;
}

 

register.html (ํšŒ์›๊ฐ€์ž… ํŽ˜์ด์ง€)

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ํšŒ์›๊ฐ€์ž… ํŽ˜์ด์ง€</title>
    <link rel="stylesheet" href="register.css">
</head>
<body>
    <div class="signup-container">
        <h2>ํšŒ์›๊ฐ€์ž…์„ ์œ„ํ•ด ์•„๋ž˜ ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.</h2>
        <form id="signup-form" action="login.html" method="post">
            <input type="text" name="name" placeholder="์ด๋ฆ„" required>
            <input type="date" name="birthdate" required>
            <input type="text" name="username" placeholder="์•„์ด๋””" required>
            <input type="password" name="password" placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ" required>

            <div class="interest-group">
                <label>๊ด€์‹ฌ๋ถ„์•ผ:</label>
                <label><input type="checkbox" name="interest" value="web"> ์›น</label>
                <label><input type="checkbox" name="interest" value="system"> ์‹œ์Šคํ…œ</label>
                <label><input type="checkbox" name="interest" value="reversing"> ๋ฆฌ๋ฒ„์‹ฑ</label>
            </div>

            <div class="gender-group">
                <label>์„ฑ๋ณ„:</label>
                <label><input type="radio" name="gender" value="female" required> ์—ฌ์„ฑ</label>
                <label><input type="radio" name="gender" value="male"> ๋‚จ์„ฑ</label>
                <label><input type="radio" name="gender" value="none"> ์„ ํƒ ์•ˆํ•จ</label>
            </div>

            <textarea name="introduction" placeholder="ํ•œ์ค„ ์†Œ๊ฐœ" rows="3"></textarea>

            <div class="button-group">
                <button type="reset" class="reset-button">์ •๋ณด ๋ฆฌ์…‹</button>
                <button type="submit" class="submit-button">ํšŒ์›๊ฐ€์ž…ํ•˜๊ธฐ</button>
            </div>
        </form>
    </div>

    <script src="register.js"></script> <!-- JavaScript ํŒŒ์ผ ์ถ”๊ฐ€ -->
</body>
</html>

 

register.js (ํšŒ์›๊ฐ€์ž… ์–‘์‹ ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’ ํ™•์ธ)

document.getElementById('signup-form').addEventListener('submit', function(event) {
    event.preventDefault(); // ๊ธฐ๋ณธ ์ œ์ถœ ๋™์ž‘์„ ๋ง‰์Œ

    // ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ด ๋ชจ๋‘ ์ฑ„์›Œ์กŒ๋Š”์ง€ ํ™•์ธ
    var form = event.target;
    var name = form.name.value.trim();
    var birthdate = form.birthdate.value;
    var username = form.username.value.trim();
    var password = form.password.value.trim();
    var gender = form.gender.value;

    if (name && birthdate && username && password && gender) {
        alert("ํšŒ์›๊ฐ€์ž… ์™„๋ฃŒ!");
        form.submit(); // ๋ชจ๋“  ๊ฒƒ์ด ์œ ํšจํ•˜๋‹ค๋ฉด ํผ ์ œ์ถœ
    } /*else {
        alert("๋ชจ๋“  ํ•„์ˆ˜ ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");
    }*/
});

 

 

register.css (ํšŒ์›๊ฐ€์ž… ํŽ˜์ด์ง€ ์Šคํƒ€์ผ)

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f0f0f0;
}

.signup-container {
    width: 40%;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.signup-container h2 {
    margin-bottom: 20px;
    font-size: 20px;
    color: #333;
}

form {
    display: flex;
    flex-direction: column;
    align-items: center;
}

form input[type="text"],
form input[type="password"],
form input[type="date"],
form textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
}

form textarea {
    resize: none;
}

.interest-group,
.gender-group {
    width: 100%;
    margin-bottom: 15px;
    text-align: left;
}

.interest-group label,
.gender-group label {
    margin-right: 10px;
}

.button-group {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.reset-button {
    width: 48%;
    padding: 10px;
    background-color: #d3d3d3;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.reset-button:hover {
    background-color: #c0c0c0;
}

.submit-button {
    width: 48%;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.submit-button:hover {
    background-color: #45a049;
}

 

welcome.html (๋กœ๊ทธ์ธ ์„ฑ๊ณต ์‹œ ์ด๋™ ํŽ˜์ด์ง€)

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>๋กœ๊ทธ์ธ ์„ฑ๊ณต ํŽ˜์ด์ง€</title>
</head>
<body>
    <h1>Welcome!</h1>
</body>

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ