css - How can I select a range of elements following a specific (.selected) element that has a different parent element? -


as can see, there .row elements parent .cell elements.

i have selected element inside .row element, want target:

an element child of parent element follows parent containing .selected

is possible in css only?

assume want select second .cell of parent next parent containing .selected

how turn background color of div containing number 13 green?

.row .cell.selected {    background-color: red  }  .row .cell.selected+.cell+.cell {    background-color: red;  }  .row .cell.selected+.cell+.cell+.cell {    background-color: red;  }  .row .cell.selected+.cell+.cell+.cell+.cell+.cell {    background-color: red;  }  #month-view .row .cell.selected+.cell {    background-color: yellow;  }  .row {    padding: 50px;  }
<div id="month-view">    <div class="row">      <div class="cell">        <div class="day"> <span>5</span></div>      </div>      <div class="cell selected">        <div class="day"><span>6</span></div>      </div>      <div class="cell">        <div class="day"><span>7</span></div>      </div>      <div class="cell">        <div class="day"><span>8</span></div>      </div>      <div class="cell">        <div class="day"><span>9</span></div>      </div>      <div class="cell">        <div class="day"><span>10</span></div>      </div>      <div class="cell">        <div class="day"><span>11</span></div>      </div>    </div>    <div class="row">      <div class="cell ">        <div class="day"><span>12</span></div>      </div>      <div class="cell">        <div class="day"><span>13</span></div>      </div>      <div class="cell">        <div class="day"><span>14</span></div>      </div>      <div class="cell">        <div class="day"><span>15</span></div>      </div>      <div class="cell">        <div class="day"><span>16</span></div>      </div>      <div class="cell">        <div class="day"><span>17</span></div>      </div>      <div class="cell">        <div class="day"><span>18</span></div>      </div>    </div>  /div>

if understood question want cell gets ".selected" class in first row gets styling in cell in same position in second row.

that not possible css only, using js. css can't give index position of ".selected" cell.

if want solution pure html , css recommend add second class ".selected-column" next rows , style after this.


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -