📜  一个div可以更改另一个div中的项目吗 css代码示例

📅  最后修改于: 2022-03-11 14:47:50.602000             🧑  作者: Mango

代码示例1
/*You can only go to the immediately next sibling (with +) or to any next sibling (with ~).
It is not possible to go up the HTML tree (to the parent). So it would be possible to go
from a hover over .beta to a child of .alpha, if you switch the their position in the HTML DOM
(.beta before .alpha). So, see this example:*/

/*Css*/

.alpha {
  position:relative;
  background-color:red;
  width:100px;
  height:50px;
}

.alpha .more {
  position:absolute;
  top:40%;
  left:40%;
  display:none
}

.beta {}

.beta:hover + .alpha .more {
  display:block;
}

/*Html*/

Make hover

Hello