简体   繁体   中英

Manipulate second div with class = row

I have the following html code. Is it possible to manipulate the second row element and how?

<style>
.span11 row{}
</style>

<div class="span11">
    <div class="row"></div>
    <div class="row"></div>
</div>

It works!

.row:nth-child(2){background:#000;}

2种方法:

  1. .row+.row{background:#000;}
  2. .row:nth-child(2){background:#000;}

Yes.. Like this.

<style>
.span11 .row{
}

.span11 .row + .row {
}
</style>

You can use a CSS3 selector nth-child

Example:

.span11 row:nth-child(2)
{
background:#ff0000;
} 

More info at the W3 Schools website .

Keep in mind that this solution is future-proof, and will work smoothly in most modern browsers, but will perform poorly on outdated versions of some browsers like Internet Explorer 9 and older.

You could use

.row:nth-child(2) {

}

you can use nth-child(child number) the

.row:nth-child(the numbed child here) {

}

like in your case you are adjusting for second child so

  .row:nth-child(2) {
  // your styles here
  }

Fiddle Link Here

Try .span11 div:nth-of-type(3n+2) { border:1px solid red;}

http://jsfiddle.net/WV3w4/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM