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

CSS가 있는

요소가 앞에 오는 모든

    요소를 선택합니다.


요소 ~ 요소 선택기를 사용하여

요소 앞에 오는

    요소를 선택합니다. 이것을 구현하기 위해 다음 코드를 실행할 수 있습니다.

    예시

    <!DOCTYPE html>
    <html>
       <head>
          <style>
             p~ul {
                color: white;
                background-color: blue;
             }
          </style>
       </head>
       <body>
          <h1>Demo Website</h1>
          <h2>Fruits</h2>
          <div>
             <p>Vegetables are good for health.</p>
             <ul>
                <li>Spinach</li>
                <li>Onion</li>
                <li>Capsicum</li>
             </ul>
          </div>
          <p>Fruits are good for health.</p>
          <ul>
             <li>Apple</li>
             <li>Orange</li>
             <li>Kiwi</li>
          </ul>
       </body>
    </html>