-
html5中伪类hover无法改变同级和父元素的属性;
-
position: absolute; 的元素相对于最近的定位祖先元素进行定位,但如果没有写具体位置(如top=10px),则会留在最近的祖先元素内,而不是在最近的定位祖先元素内。
.outside {
position: relative;
}
.tst {
height: 100px;
width: 200px;
}
.tst1 {
background-color: blue;
}
.tst2 {
background-color: pink;
}
.tst3 {
background-color: yellow;
}
img {
position: absolute;
width: 100px;
}
<body>
<div class="outside">
<div class="tst1 tst">
<img src="https://i0.hdslb.com/bfs/sycp/creative_img/202105/a59d93317da4b3d289a1f2a098ecd713.jpg@880w_388h_1c_95q" alt="">
</div>
<div class="tst2 tst">
<img src="https://i0.hdslb.com/bfs/feed-admin/5036ee4b4516b4abd08f87d3571d16ad6e3bd387.png@412w_232h_1c" alt="">
</div>
<div class="tst3 tst">
<img src="https://i0.hdslb.com/bfs/sycp/creative_img/202105/b5c8fa76759500ba4ae934e259fe4edf.jpg@412w_232h_1c" alt="">
</div>
</div>
</body>