我希望在懸停時使影像/卡片更大,然后在懸停后重置。我當前的代碼是這個
var img_css = {"width": "100%", "height": "15vw", "object-fit": "cover"};
var prev_css = $("img").css();
$( "img" ).hover(
function() {
$( this ).css((img_css));
}, function() {
$( this ).css(prev_css);
});
我的回答是基于stackoverflow的回答How to get images in Bootstrap's card to be the same height/width? 雖然這只是停留在懸停狀態。如果需要,我可以提供 html,但它看起來像<img style="" src="https://images.pexels.com/photos/2033992/pexels-photo-2033992.jpeg">
uj5u.com熱心網友回復:
.card-img-top{
width:50px;
height:50px;
float:left;
}
.card-img-top:hover{
width:100px;
height:100px;
}
<img style=""class="card-img-top" src="https://images.pexels.com/photos/2033992/pexels-photo-2033992.jpeg">
<img style=""class="card-img-top" src="https://images.pexels.com/photos/2033992/pexels-photo-2033992.jpeg">
<img style=""class="card-img-top" src="https://images.pexels.com/photos/2033992/pexels-photo-2033992.jpeg">
<img style=""class="card-img-top" src="https://images.pexels.com/photos/2033992/pexels-photo-2033992.jpeg">
<img style=""class="card-img-top" src="https://images.pexels.com/photos/2033992/pexels-photo-2033992.jpeg">
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/486588.html
上一篇:嘗試用P替換Input
