adjacent sibling combinator ( + ) separates two selectors and matches the second element only if it immediately follows the first element, and both are children of the same parent element .

/* Paragraphs that come immediately after any image */
img + p {
  font-weight: bold;
}
					

句法

former_element + target_element { style properties }
					

范例

CSS

li:first-of-type + li {
  color: red;
}
					

HTML

<ul>
  <li>One</li>
  <li>Two!</li>
  <li>Three</li>
</ul>
					

结果

规范

规范 状态 注释
Selectors Level 4
The definition of 'next-sibling combinator' in that specification.
工作草案 Renames it the "next-sibling" combinator.
Selectors Level 3
The definition of 'Adjacent sibling combinator' in that specification.
推荐
CSS Level 2 (Revision 1)
The definition of 'Adjacent sibling selectors' in that specification.
推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Adjacent sibling combinator ( A + B ) Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 7 注意事项
完整支持 7 注意事项
注意事项 Internet Explorer 7 doesn't update the style correctly when an element is dynamically placed before an element that matched the selector.
注意事项 In Internet Explorer 8, if an element is inserted dynamically by clicking on a link the first-child style isn't applied until the link loses focus.
Opera 完整支持 3.5 Safari 完整支持 1 WebView Android 完整支持 ≤37 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 10.1 Safari iOS 完整支持 1 Samsung Internet Android 完整支持 1.0

图例

完整支持

完整支持

见实现注意事项。

见实现注意事项。

另请参阅

元数据

  • 最后修改: