js1-2

by wang_siang

HTML

<div class="all">
        <div class="block">
            <label for="name">客戶姓名:</label>
            <input type="text" id="name">
        </div>
        <div>
            <button type="button" onclick="clickBtn1()">我要訂購</button>
            <button type="button" onclick="clickBtn2()">認識工廠</button>
        </div>
    </div>

CSS

* {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            width: 100%;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .all {
            color: rgb(0, 0, 0);
            font-size: 18px;
            font-weight: 600;
            padding: 50px;
            display: flex;
            gap: 40px;
            flex-direction: column;

            border-radius: 8px;
        }

        .all div {
            display: flex;
            justify-content: space-between;
            gap: 10px;
        }

        .all button {
            padding: 10px 20px;
            color: white;
            font-size: 18px;
            font-weight: 600;
            background-color: #5280ff;

            box-shadow: 5px 5px 0px black;

            border: 3px solid black;

            transition: all 0.3s ease;
            cursor: pointer;

        }

        .all button:hover {
            background-color: #fff;
            color: #5280ff;
            border: 3px solid #5280ff;
            box-shadow: 5px 5px 0px #5280ff;
        }

        .all button:active {
            background-color: #fff;
            color: #5280ff;
            border: 3px solid #5280ff;
            box-shadow: 0px 0px 0px #5280ff;
            transform: translateY(4px);
        }

        .block {
            display: flex;
            align-items: center;
        }

        .all input {
            padding: 8px;
            font-size: 16px;
            border: 3px solid black;
            box-shadow: 5px 5px 0px #000000;
            outline: none;
            cursor: pointer;
        }

        .all input:focus {
            border: 3px solid #5280ff;
            box-shadow: 5px 5px 0px #5280ff;
            transition: all 0.6s ease;
            color: #5280ff;
        }

        .block:focus-within label {
            color: #5280ff;
            transition: color 0.6s...

JavaScript

function clickBtn1() {
            let name = document.getElementById('name').value;
            alert(name + '您好!謝謝您對我們的衣服有興趣!請致電 0987-654-321,會有專人提供您報價!');
        };

        function clickBtn2() {
            alert('我們工廠位於新北市,通過國際 ISO9001 認證,品質讓您放心!');
        };