今天的參考
https://www.youtube.com/watch?v=BMphVl9suxA
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>測試</title>
<link href="C1.css" rel="stylesheet">
</head>
<body>
<div class="INP">
<input type="text" required="required">
<span>姓名</span>
</div>
<div class="INP">
<input type="text" required="required">
<span>學號</span>
</div>
</body>
</html>
CSS
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins',sans-serif;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
flex-direction: column;
gap: 30px;
background: #121214;
}
.INP{
position: relative;
width: 250px;
}
.INP input{
width: 100%;
padding: 10px;
border: 1px solid rgba(255, 255, 255, 0.25);
background: #121214;
border-radius: 5px;
outline: none;
color: #FFF;
color-size: 1em;
}
.INT span{
position: absolute;
left: 0;
padding: 10px;
pointer-events: none;
font-size: 1em;
color: rgba(255, 255, 255, 0.25);
text-transform: uppercase;
}
.INP input:valid ~ span,
.INP input:focus ~ span{
color: #34C9FF;
}
成果(滑鼠點擊輸入框,字會變色)
今天先這樣,明天繼續