當我將鼠標懸停在 img 標簽下方以顯示文本時,我需要制作動畫(必須是緩慢地顯示文本的動畫),但這還不是全部。它還必須在文本顯示時向下移動其他內容,并在文本消失時返回(何時不是)徘徊)。非常重要的是,顯示的文本必須是動畫的并且可以返回。我不在乎它是否適用于 jq 或 css 或兩者都只需要工作。我是一個初學者,所以也許顯然我只是沒有看到它。HTML: <div class="first-block"></div> <div class="secend-block"> <div class="box"> <img src="/Test/beach.jpg" alt="beach" width="200px" height="200px"> <p>asdasdasssssssssssssssssssssss asdddddddddddddddddddddd asdaaaadsssssssssssadsadsdasd adsssssssssssssssssadsadsadsa </p> </div> </div> <div class="third-block"> <h1>some content</h1> <h1>some content</h1> <h1>some content</h1> <h1>some content</h1> </div>CSS: .first-block{ width: 99%; height: 100px; background: #f10000;}.secend-block{ width: 99%; height: auto; background: #ffffff;}.secend-block .box{ width: 200px; padding-top: 10px; margin: 0px auto;}.secend-block .box p{ display: none;}.third-block{ width: 99%; height: auto; background: #4400ff;}
1 回答

肥皂起泡泡
TA貢獻1829條經驗 獲得超6個贊
使用.class:hover
基本上,當.image懸停時,我們想要更改 的樣式.text。CSS 查詢.image:hover + .text選擇該.text元素,該元素之前有一個圖像懸停在該元素之前。
.image {
width: 250px;
}
.text {
max-height: 0px;
overflow: hidden;
transition: max-height 1s;
}
.image:hover + .text {
max-height: 32px;
}
<div class="wrapper">
<img class="image" src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__340.jpg" />
<p class="text">This is some text</p>
</div>
<div class="wrapper">
<img class="image" src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__340.jpg" />
<p class="text">This is some text</p>
</div>
- 1 回答
- 0 關注
- 124 瀏覽
添加回答
舉報
0/150
提交
取消