gpt4 book ai didi

jquery - 如何仅应用过渡定义的元素,而不是其子元素?//简单的 Accordion

转载 作者:行者123 更新时间:2023-11-28 18:22:05 26 4
gpt4 key购买 nike

我处于这样一种情况,我需要在 li 的宽度上使用过渡,而不是在其子级 img

上使用

li 元素中有小图片。当用户悬停的 li 元素 width 正在扩展内部图像时。

我正在尝试使用 no transition 扩展图像,但它的父级 li 需要使用 transition 扩展。

Here is jsFiddle example.

CSS:

ul.images { position:fixed; top:0px;left:0px; width:2660px; }
ul.images li {
float:left;
margin-right:1px;
background: red;
overflow:hidden;
height: 500px;
padding:10px;
width:50px;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
transition: all 0.5s ease;
}

ul.images li img {
float:left; width:100%; height: auto;

/* this doesn't work */
-webkit-transition: all 0s;
-moz-transition: all 0s;
-o-transition: all 0s;
-ms-transition: all 0s;
transition: all 0s;
}
ul.images li.active { float:left; width: 270px; }
ul.images li.active img { height: 100%; }

jQuery:

$('ul.images li').first().addClass('active');
$('ul.images li').bind({
mouseenter: function() {
$('ul.images li').removeClass('active');
$(this).addClass('active');
}
});

最佳答案

您可以尝试为 px 而不是 % 的图像设置固定的 width。因为 % 将采用容器。

ul.images { position:fixed; top:0px;left:0px; width:2660px; }
ul.images li {
float:left;
margin-right:1px;
background: red;
overflow:hidden;
height: 500px;
padding:10px;
width:50px;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
transition: all 0.5s ease;
overflow:hidden;
}

ul.images li img {
float:left; width:50px; height: auto;
}
ul.images li.active { float:left; width: 270px; }
ul.images li.active img { width:270px; height: 100%; }

并在 li 上添加 overflow;hidden

DEMO

希望我没听错。祝你好运!

关于jquery - 如何仅应用过渡定义的元素,而不是其子元素?//简单的 Accordion ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16605014/

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