Home >Web Front-end >CSS Tutorial >How to use CSS + (plus sign) selector

How to use CSS + (plus sign) selector

青灯夜游
青灯夜游Original
2019-02-12 17:09:595582browse

In CSS, the " " symbol selector is used to select elements that immediately follow the specified element but are not inside the specific element. The following article will introduce it in detail, I hope it will be helpful to everyone.

How to use CSS + (plus sign) selector

" " symbol selector

In CSS, the " " symbol selector is called the relative The neighbor selector is used to select another element immediately following the specified element under the same parent element. [Video tutorial recommendation: CSS tutorial]

Basic sentence structure:

元素E + 元素F{
 //CSS属性
}

Instructions: All major browsers Supports " " symbol selector; but when running in IE8, must be declared.

Simple code example

The following is a simple code example to see how to use it.

<!DOCTYPE html> 
<html> 
    <head> 
    <meta charset="UTF-8">
        <title>“+”符号选择器</title> 
        <style> 
        body { 
                text-align:center; 
            } 
            h1 { 
            color:red; 
            } 
            div{
            font-size:25px; 
            }
            h2+div { 
                font-size:20px; 
                font-weight:bold; 
                display:inline; 
                background-color: yellow; 
                color:green; 
            } 
        </style> 
    </head> 
    <body> 
        <h1>PHP</h1> 
            <div>HTML</div> 
            <h2>CSS</h2> 
            <div>Javascript</div> 
            <div>MySQL</div> 
    </body> 
</html>

Rendering:

How to use CSS + (plus sign) selector

It can be seen that h2 div{} is the first div element selected immediately after the h2 element. and add styles to it.

The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

The above is the detailed content of How to use CSS + (plus sign) selector. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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