Home > Web Front-end > HTML Tutorial > CSS选择器加号+的作用是什么_html/css_WEB-ITnose

CSS选择器加号+的作用是什么_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:27:15
Original
1561 people have browsed it

CSS选择器加号+的作用是什么:
此选择器能够匹配指定元素后面紧邻的兄弟元素。
代码实例如下:

<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">#items{  width:900px;  height:auto;  margin:0 auto;  padding:5px 0;  clear:both;}#items ul, #items li{  list-style:none;}#items li{  width:500px;  height:28px;  text-align:left;  padding-left: 0px;  line-height:28px;  border-bottom:dashed 1px #CCC;  cursor:pointer;}.first + li{  color:red;}</style></head><body><div id="items">  <ul>    <li class="first">蚂蚁部落欢迎您,只有努力奋斗才会有美好的未来</li>    <li>没有任何人一开始就是高手,必须要好好学习</li>    <li>本站的url地址是softwhy.com</li>    <li>每一天都是新的,所以要好好真心当前时间</li>    <li>div css教程里面有大量详实的代码</li>  </ul></div></body></html>
Copy after login

上面的代码可以将class属性值为first的li元素后面紧邻的第一个li元素的字体颜色设置为红色。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=18186

更多内容可以参阅:http://www.softwhy.com/divcss/

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template