IT/HTML, CSS

선택자

iamhyeon 2024. 11. 2. 17:42

자식셀렉터

 div > span > input.form_control { 
    ... 
}
<div>
	<span>
    	<input class="form_control" />
	</span>
 </div>

 

자손셀렉터

- 계층구조 공백으로 표현

- 순차적일 필요 없다

div span input.form_control { 
    ... 
}
<div> 
    ... ? ... 

	 <span> ...?... 
     	<input class="form_control" /> ...?... 
	</span> 
    ... ? ... 
</div>

속성셀렉터

a[href] href 속성을 갖는 a태그
a[href="#"] href 속성값이 "#"인 a태그
#hello[method="post"] method속성값이 "post"인 id가 hello인 태그

 

가상클래스

a:link { ... } 
a:visited { ... } 
a:hover { ... } 
a:active { ... }

 

n번째 요소

 

:first-child

:last-child

:nth-child(2)

 

:nth-child(odd)

:nth-child(2n)

:nth-child(3n)

:nth-last-child(숫자)    뒤에서부터 요소 카운트

 

 

반응형

'IT > HTML, CSS' 카테고리의 다른 글

모달 창 뒷부분 스크롤 막기  (0) 2024.11.11
선택자를 특정 클래스 바로 밑에 있는 요소에만 적용  (0) 2024.11.03
Responsive 반응형 웹 디자인  (1) 2024.10.06
웹 폰트  (2) 2024.10.06
가상요소  (0) 2024.09.08