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>