question 1: the combined class selector selects the node behind it, so how do you choose the previous one?
<a href="https://segmentfault.com" class="p1">This is a paragraph.1</a>
<a href="https://segmentfault.com" class="p2">This is a paragraph.2</a>
.p1:hover+.p2 {
outline: 10px double purple;
}
.p2:hover~.p1 {
outline: 10px double purple;
}
actually want to do is: mouse hover p1, give p2 a box; mouse hover p2, give p1 a box. However, the second half of the sentence is invalid.
tried combination selector
. They all select nodes backward and cannot move forward.?
question 2: how do I select two or more elements with different parents?
is still the example above. The HTML I started with is written like this
<div>
<a href="https://segmentfault.com" class="p1">This is a paragraph.1</a>
<a href="https://segmentfault.com" class="p2">This is a paragraph.2</a>
</div>
later found that the combination choices are all above, which seems to have nothing to do with it. How can I achieve the purpose of question 1? brothers
descendants
, like which belongs to two