gpt4 book ai didi

html - 样式化 div 悬停 Action 不移动其他元素

转载 作者:太空宇宙 更新时间:2023-11-04 00:56:52 27 4
gpt4 key购买 nike

我在屏幕上有一个包含 100 个元素的列表,有些描述比 div 的宽度长,所以我将它的剩余部分剪掉以保持它们的大小相同。在悬停时,我想显示所有数据。我设法做到了,但现在当我将鼠标悬停在一个元素上时,下面的所有元素都在向下移动。我想将悬停的 div 向前移动并将所有其他图 block 保持在同一位置。

Demo here

<div class="album-item">
<div class="album-img"><img src="https://is1-ssl.mzstatic.com/image/thumb/Music124/v4/1a/69/cf/1a69cf82-2cfe-a7e1-a79c-cb9d7d67b710/886447513651.jpg/170x170bb-85.png"></div>
<div class="album-card">
<div class="name">Rent (Original Soundtrack of the Fox Live Television Event)</div>
<div class="artist">Original Television Cast of Rent Live</div>
<div class="date">February 1, 2019</div>
</div>
</div>

<div class="album-item">
<div class="album-img"><img src="https://is1-ssl.mzstatic.com/image/thumb/Music124/v4/1a/69/cf/1a69cf82-2cfe-a7e1-a79c-cb9d7d67b710/886447513651.jpg/170x170bb-85.png"></div>
<div class="album-card">
<div class="name">Rent (Original Soundtrack of the Fox Live Television Event)</div>
<div class="artist">Original Television Cast of Rent Live</div>
<div class="date">February 1, 2019</div>
</div>
</div>
.album-item {
background-color: gray;
width: 170px;
margin: 25px;
}

img {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
border-radius: 5px;
-webkit-transition: all 0.6s cubic-bezier(0.15, 0.8, 0.4, 1);
transition: all 0.6s cubic-bezier(0.15, 0.8, 0.4, 1);
opacity: 0.8;
border: 1px solid transparent;

&:hover {
-webkit-transform: scale(1.1, 1.1);
transform: scale(1.1, 1.1);
opacity: 1;
border-color: yellow;
cursor: pointer;
}
}

.album-card {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;

&:hover {
color: yellow;
white-space: normal;
height: 100%;
}

.name {
font-size: 110%;
font-weight: 550;
}

.artist {
font-weight: 300;
}

.date {
font-weight: 100;
font-style: italic;
font-size: 80%;
}
}

我希望图像描述显示在下面图像的顶部,这样它就不会移动整个列表。

最佳答案

不复制内容:https://codepen.io/dmegatool/pen/jdmOgq

这就是您想要的效果吗?

新的CSS:

.album-item {
width: 170px;
margin: 25px;
margin-bottom:75px;
}

img {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
border-radius: 5px;
-webkit-transition: all 0.6s cubic-bezier(0.15, 0.8, 0.4, 1);
transition: all 0.6s cubic-bezier(0.15, 0.8, 0.4, 1);
opacity: 0.8;
border: 1px solid transparent;


&:hover {
-webkit-transform: scale(1.1, 1.1);
transform: scale(1.1, 1.1);
opacity: 1;
border-color: yellow;
cursor: pointer;
}
}

.album-card {
display:block;
position:absolute;
width:170px;
background-color: gray;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;


&:hover {
color: yellow;
white-space: normal;
height: auto;
z-index:10;
}

.name {
font-size: 110%;
font-weight: 550;
}

.artist {
font-weight: 300;
}

.date {
font-weight: 100;
font-style: italic;
font-size: 80%;
}
}

未修改的 HTML:

<div class="album-item">
<div class="album-img"><img src="https://is1-ssl.mzstatic.com/image/thumb/Music124/v4/1a/69/cf/1a69cf82-2cfe-a7e1-a79c-cb9d7d67b710/886447513651.jpg/170x170bb-85.png"></div>
<div class="album-card">
<div class="name">Rent (Original Soundtrack of the Fox Live Television Event)</div>
<div class="artist">Original Television Cast of Rent Live</div>
<div class="date">February 1, 2019</div>
</div>
</div>

<div class="album-item">
<div class="album-img"><img src="https://is1-ssl.mzstatic.com/image/thumb/Music124/v4/1a/69/cf/1a69cf82-2cfe-a7e1-a79c-cb9d7d67b710/886447513651.jpg/170x170bb-85.png"></div>
<div class="album-card">
<div class="name">Rent (Original Soundtrack of the Fox Live Television Event)</div>
<div class="artist">Original Television Cast of Rent Live</div>
<div class="date">February 1, 2019</div>
</div>
</div>

关于html - 样式化 div 悬停 Action 不移动其他元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54485064/

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