1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| <div class="input_container"> <input type="text" id="acc" placeholder=" "> <label for="acc">Account</label> </div> <div class="input_container"> <input type="password" id="psw" placeholder=" "> <label for="psw">Password</label> </div> <style> .input_container { display: flex; place-items: center; position: relative; --color: #114514; --color-focus: #191981; margin-bottom: 16px; } .input_container > input { border: 0; outline: 0; border: 0.1rem solid var(--color); padding: 0.5rem; border-radius: 6px; } .input_container > label { position: absolute; top: 50%; left: 0.7rem; transform: translateY(-55%); color: var(--color); transition: 0.2s; background: white; } .input_container > input:focus, .input_container > input:not(:placeholder-shown) { border: 0.1rem solid var(--color-focus); } .input_container > input:focus + label, .input_container > input:not(:placeholder-shown) +label { color: var(--color-focus); top: 0; font-size: .8rem; } </style>
<div style="position: relative;padding:8px"><button data-component="text" onclick="confirm()" style="font-size: 16px; background-color: #1f883d; border-color: #1f232826; color: #ffffff; border-radius: .375rem; display: inline-flex; justify-content: center; align-items: center; height: 2rem; padding: 0 .75rem; border-style: solid; border-width: 1px;">Confirm</button></div>
<script> function confirm(){ let acc = document.getElementById('acc').value let psw = document.getElementById('psw').value if ( acc && psw ){ alert(`账号: ${acc} \n密码: ${psw}`) } else { alert('账号或密码未输入!') } } </script>
|