Computer >> 컴퓨터 >  >> 프로그램 작성 >> CSS

CSS의 역할:마지막 유형 선택기

<시간/>

CSS :last-child 선택기를 사용하여 부모의 마지막 자식인 모든

요소의 스타일을 지정합니다.

예시

다음 코드를 실행하여 :last-child 선택기 −

를 구현할 수 있습니다.
<!DOCTYPE html>
<html>
   <head>
      <style>
         p:last-of-type {
            background: orange;
         }
      </style>
   </head>
   <body>
      <h2>Heading</h2>
      <p>This is demo text1.</p>
      <p>This is demo text2.</p>
      <p>This is demo text3.</p>
   </body>
</html>