div > div > .-6ren">
gpt4 book ai didi

css - Bootstrap 列在悬停时放大(如 Netflix)

转载 作者:行者123 更新时间:2023-11-28 01:28:34 24 4
gpt4 key购买 nike

我有一个如下所示的 GridView :

 jQuery(window).resize(function(evt) {
jQuery(".grid-content > div > div > .channelImage").height(jQuery(".grid-content > div > div > .channelImage").width());
});
jQuery(function() {
jQuery(window).resize();
});
    body {
background-color: rgba(48, 48, 48, 1);
}

body>.container {
max-width: 90vw;
}

.previewrow {
height: 40vh;
}

.preview {
position: absolute;
left: 0;
right: 0;
height: 40vh;
}

.grid-content>div>div {
margin: 3vw;
box-shadow: 6px 6px 6px black;
border: 1px solid white;
text-align: center;
color: white;
}

.grid-content>div {
float: left;
}

.grid-content>div>div>.channelImage {}

.grid-content>div>div>.channelImage:before {
content: " ";
display: inline-block;
height: 100%;
vertical-align: middle;
}

.grid-content>div:hover>div {
box-shadow: 0 0 0 black;
transition: all 0.25s;
margin: 1em;
}
<!-- Bootstrap and JavaScript -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap-grid.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<body>
<div class="container body-content">
<div class="grid-content">

<!-- One -->
<div class="col-lg-3 col-md-4 col-sm-3 col-xs-2">
<div>
<div class="channelImage">
<img width="30%" />
</div>
<div>
Some text
</div>
</div>
</div>
<!-- Two -->
<div class="col-lg-3 col-md-4 col-sm-3 col-xs-2">
<div>
<div class="channelImage">
<img width="30%" />
</div>
<div>
Some text
</div>
</div>
</div>
<!-- Three -->
<div class="col-lg-3 col-md-4 col-sm-3 col-xs-2">
<div>
<div class="channelImage">
<img width="30%" />
</div>
<div>
some text
</div>
</div>
</div>
<!-- Four -->
<div class="col-lg-3 col-md-4 col-sm-3 col-xs-2">
<div>
<div class="channelImage">
<img width="30%" />
</div>
<div>
Some text
</div>
</div>
</div>
<!-- Five -->
<div class="col-lg-3 col-md-4 col-sm-3 col-xs-2">
<div>
<div class="channelImage">
<img width="30%" />
</div>
<div>
Some text
</div>
</div>
</div>
</div>
</div>
</body>

如您所见,只要用户将鼠标悬停在正方形上,我就会尝试放大正方形。但是调整边距会导致其他框被移动。我怎样才能扩大方 block ,使它们不会移动其他方 block ?

最佳答案

通过使用以下 CSS 并将其应用于您想要影响的元素,您可以在不移动任何东西的情况下使某些东西变大:

.class {
transition: .10s, transform .10s ease;
-moz-transition: .10s, transform .10s ease;
-webkit-transition: .10s, transform .10s ease;
}

.class:hover {
-ms-transform: scale(1.01); /* IE 9 */
-webkit-transform: scale(1.01); /* Safari */
transform: scale(1.01);
}

作为奖励,您可以在单击它时使其缩小以产生类似 Spring 的效果:

.class:active {
-ms-transform: scale(0.99); /* IE 9 */
-webkit-transform: scale(0.99); /* Safari */
transform: scale(0.99);
}

关于css - Bootstrap 列在悬停时放大(如 Netflix),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51115534/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com