li:nth-of-type(odd){ margin-left: 5px;}奇数行 li:nth-of-type(even){margin-left: 5px;}偶数行 </style> <ulid="Ulist"> <> <li>2</li> <
<style> #Ulist li:nth-of-type(odd){margin-left:20px;}奇数行 #Ulist li:nth-of-type(even){margin-left:10px;}偶数行 <style> <ul id="Ulist"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> </ul>...
li:nth-of-type(odd) {...} /*--这是奇数行--*/li:nth-of-type(even) {...} /*--这是偶数行--*/
.mk_list li:nth-of-type(odd) .mk_left{ float:left; width:300px; height:225px; overflow:hidden} .mk_list li:nth-of-type(odd) .mk_right{ float:right; width:850px; height:auto; } .mk_list li:nth-of-type(odd) .mk_right h1{ color:#333; font-size:22px; line-height:35px;}...
总结:1 1、使用ul、li标签创建一个列表,设置ul标签的class属性为mycl。 2、在css标签内,通过class设置ul列表的样式,定义它的序号为空,宽度为250px,文字颜色为白色。 3、在css标签内,通过class和选择器nth-of-type(odd)设置奇数行的li元素的样式,使用background属性将其背景设置为红色。 4、在...
<style> #Ulist li:nth-of-type(odd){margin-left:20px;}奇数行 #Ulist li:nth-of-type(even){margin-left:10px;}偶数行 <style> <ul id="Ulist"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> ...
第n个li的样式:li:nth–child(n){background:#000; } 倒数第二个li的样式:nth–last–of–type(2){background:#000; } 奇数列表:li:nth–child(odd){background:#f00; } 偶数列表:li:nth–child(even){background:#f00; } 手机浏览(小程序) ...
4种方法:1、用“:first-child”给第1个li加样式,语法“li:first-child{样式代码}”;2、用“:last-child”给最后1个li加样式,语法“li:last-child{样式}”;3、用“li:nth-of-type(N){样式代码}”给第N个li加样式;4、用“li:nth-child(N){样式代码}”给第N个li加样式。
CSS3可以直接选择奇偶数,,<style>#list li:nth-of-type(odd){ background:#00ccff;}奇数行 #list li:nth-of-type(even){ background:#ffcc00;}偶数行 </style><ul id="list"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li></ul>如果不想用CSS3,...
nth-of-type()可以判断奇偶,虽然有可能低版本IE不支持,但是视觉效果的话低版本放弃就完了。<style>ul li:nth-of-type(odd){奇数行样式} ul li:nth-of-type(even){偶数行样式}<style> 如果我说服不了你,一定要js的话,那么继续:<script id="jquery_182" type="text/javascript" class="library"...