프로그램/html

css로 선택자 반복

milktea.kang 2010. 12. 14. 12:10
div p:nth-child(odd) /* div안에 홀수로 출현하는 자식요소인 p요소에 적용 */
div p:nth-child(2n+1) /* 위와 같다 */
div p:nth-child(even) /* div안에 짝수로 출현하는 자식요소인 p요소에 적용 */
div p:nth-child(2n) /* 위와 같다 */
/* 아래와 같이 적으면 4가시 색이 순서대로 반복된다 */
div p:nth-child(4n+1) { color:navy;}
div p:nth-child(4n+2) { color:green;}
div p:nth-child(4n+3) { color:maroon;}
div p:nth-child(4n+4) { color:purple;}
한줄 흰색 한줄 회색 그렇게 반복시키는 스타일이라면 이해될까?