0

テーブルを使用するのとは対照的に、私はかつてdivであった構造化されたセクションを持っています。表示される各セクション間で行の色を動的に切り替える方法があるかどうか疑問に思っています。

<div>
  <name-section></name-section> (blue)
  <address-section></address-section> (green)
  <city-section></city-section> (blue)
  <postal-section></postal-section> (green)
</div>

4

1 に答える 1

4

このjsFiddleをチェックしてください。これはcssを使用してそれを行います。

div > *:nth-child(even) {background: green}
div > *:nth-child(odd) {background: blue}
于 2013-02-04T17:04:12.530 に答える