Jump to content
php.lv forumi

Selektori, parenta augšējais kaimiņš


Infants

Recommended Posts

Labdien. Ir koda gabaliņš:

<div>
  <h5>CAT 1</h5>
    <ul>
      <li>sub1</li>
      <li>sub2</li>
      <li>sub3</li>
      <li>sub4</li>
   </ul>

   <h5>CAT 2</h5>
   <ul>
      <li>sub5</li>
      <li class="active">sub6</li>
      <li>sub7</li>
      <li>sub8</li>
   </ul>
</div>

 

Nevaru atrast, kā 'pa skaisto' css'ā atrast to <h5>, kuram blakus (pēc kura) ir <ul><li class="active">

 

P.s. Ar jquery parent('ul').prev('h5') strādā smuki, bet vai tas ir iespējams ar css?

Link to comment
Share on other sites

 

Varbūt kaut kādos hipsterjaunākajā css var (bet varbūt arī nevar).

Nāksies vien taisīt parent child child child. Uzliec tam main divam kādu klasi/id un tad

 

div.klase ul li.active { border: 1px solid red; }

 

Kā diez šis atradīs "h5", kas nav "ul" child elements?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...