Home > Web Front-end > HTML Tutorial > CSS adjacent selector (7)_html/css_WEB-ITnose

CSS adjacent selector (7)_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:46:17
Original
964 people have browsed it

1. Adjacent selectors

The front and rear parts of adjacent selectors are separated by a plus sign ( ). The selection inverse characters of the two parts are of the same level in structure. Relationships, such as

adjacent selectors, specify adjacent elements based on the left selector, and then search for elements behind the adjacent elements that match the right selector

2. Simple example

<!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/html; charset=utf-8" /><title>相邻选择器</title><style type="text/css">/*选择中id为wrap最下的p标签使用相信选择器*/#sub_wrap + p{    font-size:22px;    color:red;    }</style></head><body><div id="wrap"><div id="sub_wrap"><h2 class="news">标题2</h2><p class="news">标题2下的段落</p><span class="news">标题2下的span</span></div><strong><p>相邻段落</p></strong></div></body></html>
Copy after login

Related labels:
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