Title rewritten to: CSS > Select first element in tree
P粉237125700
P粉237125700 2023-08-31 19:48:34
0
1
425
<p>I've been trying to select only the first blockquote in the body of the email, which goes something like this: </p> <pre class="brush:php;toolbar:false;"><div class="myclass"> <br><p></p> <div><div> <!--sometimes less, sometimes more divs--> <blockquote> <!--The blockquote I want to select--> <div> <div> <br> <blockquote> <Wait...> </blockquote> </div> </div> </blockquote> </div></div> </div></pre> <p>The problem is, the formatting may vary from email to email, and there may be one or more divs before the first blockquote,</p><p> So use: </p> <pre class="brush:php;toolbar:false;">.myclass > div > div > blockquote {}</pre> <p>Not always valid,</p><p> This: </p> <pre class="brush:php;toolbar:false;">.myclass blockquote:first-of-type {}</pre> <p>Each blockquote will be selected</p> <p>So I only want to select the first blockquote regardless of its position on the html tree. </p>
P粉237125700
P粉237125700

reply all(1)
P粉949190972

Like this? Selects the first nested blockquote of the container .myclass, but does not select any blockquote## that is a child of the first blockquote #.

.myclass blockquote:not(blockquote blockquote) {
  background-color: red;
}
<div class="myclass">
  <br>
  <p></p>
  <div>
    <div>
      <!--有时少有时多的div-->
      <blockquote>
        <!--我想选择的blockquote-->
        <div>
          <div> <br>
            <blockquote>
            </blockquote>
          </div>
        </div>
      </blockquote>
    </div>
  </div>
</div>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!