css3里面怎样找到li的奇数跟偶数

html-css012

css3里面怎样找到li的奇数跟偶数,第1张

步骤如下:ul li:nth-child(2n);ul li:nth-child(2n+1)

CSS部分:

.list {width:500pxmargin:0 auto}

.list ul {background:url(http://www.bluebirdsky.cn/images/upfiles/row_bg.gif)}

.list li {height:25pxline-height:25pxtext-align:leftpadding-left:10px}

Demo演示

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<meta name="Author" content="青鸟" />

<meat name="Author BlogURL" content="http://www.bluebirdsky.cn/[Bluebirdsky]"

步骤如下:ul li:nth-child(2n);ul li:nth-child(2n+1)

CSS部分:

.list {width:500pxmargin:0 auto}

.list ul {background:url(http://www.bluebirdsky.cn/images/upfiles/row_bg.gif)}

.list li {height:25pxline-height:25pxtext-align:leftpadding-left:10px}

Demo演示

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<meta name="Author" content="青鸟" />

<meat name="Author BlogURL" content="http://www.bluebirdsky.cn/[Bluebirdsky]"