[英]image magnifier reset jquery bootstrap
我希望在懸停時使圖像/卡片更大,然后在懸停后重置。 我當前的代碼是這個
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=""class="card-img-top" src="https://images.pexels.com/photos/2033992/pexels-photo-2033992.jpeg">
.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">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.