본문 바로가기
[HTML & CSS]

[HTML & CSS] 예제

by 북방바다코끼리표범 2023. 8. 4.

배운것들을 응용해서 간단한 문제를 풀어보자

 

Document

반응 선택자 만들어보기

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/17_etc_action.css">
</head>
<body>
    <!-- 반응 선택자 예제 -->
    <h1>반응 선택자</h1>
    
</body>
</html>

/* 반응 선택자 */
/* 선택자 : hover - 마우스가 위로 올라가면 디자인 적용 */
<style>
h1:hover {
  color: red;
}

/* 선택자 :active - 마우스 클릭하면 디자인 적용 */
h1:active {
  color: blue;
}
</style>
Document

상태 선택자 만들어보기

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./css/18_etc_state.css" />
  </head>
  <body>
    <!-- 상태 선택자 예제 -->
    <h2>사용 가능</h2>
    <input type="text" />
    <h2>사용 불가능</h2>
    <!-- disabled="disabled" : 입력 못하게 막는 속성 -->
    <input type="text" disabled="disabled" />
  </body>
</html>

/* 상태 선택자 */
/* input: 현재 입력 가능한 상태시 디자인 적용 */
input:enabled {
  background-color: white;
}

/* input: 현재 입력 불가능한 상태시 디자인 적용 */
input:disabled {
  background-color: rgba(255, 255, 255, 0.5);
}

/* input: 커서가 있을 때(포커스) 디자인 적용 */
input:focus {
  background-color: yellow;
}
Document

사용 가능

사용 불가능