반응형
focus-within : focused인 자식을 가진 부모 엘리먼트에 적용되는 것.
<!DOCTYPE html>
<html lang="kr">
<head>
<title>The Nick Times</title>
<style>
body {
height: 1000vh;
margin: 50px;
}
form {
border: 1px solid salmon;
display: flex;
flex-direction: column;
padding: 20px;
}
form:focus-within {
border-color: seagreen;
}
</style>
</head>
<body>
<form>
<input type="text" name="" id="" />
<input type="text" name="" id="" />
<input type="text" name="" id="" />
</form>
</body>
</html>
form의 자식인 3개 input 중에
하나라도 focused 되면
border-color가 seagreen이 된다.
결과
반응형
'2. CSS' 카테고리의 다른 글
CSS ::placeholder (플레이스홀더 문구 색상 바꾸기) (0) | 2024.11.30 |
---|---|
CSS 마우스 hover시 input 박스 색상 변경하기 (0) | 2024.11.30 |
CSS visited, hover, focus 동시에 사용하기 (1) | 2024.11.30 |
CSS visited 로 링크 색상 변경하기 (0) | 2024.11.30 |
CSS focus를 이용해서 input 박스 강조하기 (0) | 2024.11.30 |