gpt4 book ai didi

jquery - 将 Logo 从一个变形为另一个 css

转载 作者:太空宇宙 更新时间:2023-11-04 09:34:19 28 4
gpt4 key购买 nike

嘿,我正在尝试实现 Logo 的以下变形效果,我试图在 jquery 的帮助下做到这一点,但无法弄清楚我是如何添加 css 转换的:

这就是我想要达到的效果(左上角)标志: http://marquez.thememountain.com/regular/

我试着这样做:

HTML:

<a href="index.html"><img class="o-logo__main" src="img/logo/logo.svg"></a>

CSS:

.o-logo__main {
left: span(.3);
position: fixed;
top: span(.5);
width: 85px;
z-index: 1;
}

J查询:

$(document).scroll(function(){
var h = $(".flexslider__container").height() * 1.5;
var t1 = $(".c-quote").offset().top;
if(($(this).scrollTop() + h) >= t1)
{
$('.o-logo__main').attr('src','img/logo/logo2.svg');

}
else{

}
});

最佳答案

这个的非常基本的版本:

$(window).scroll(function() {
// I just set this to trigger after 30px of scroll, use whatever you like.
if ($(this).scrollTop() >= 30) {
$('.logo').addClass('scrolled');
} else  {
$('.logo').removeClass('scrolled');
}
});
body, html { height: 200%; }

.logo {
position: fixed;
overflow: hidden;
margin: 1em;
font-size: 2em;
}

.name,
.glyph {
transition: all .5s ease;
display: inline-block;
will-change: opacity, transform;
}

.name {
font-weight: 300;
text-transform: uppercase;
letter-spacing: 0.3em;
}

.glyph {
font-weight: bold;
opacity: 0;
position: absolute;
top: 0; left: 0;
transform: translateX(4em);
}

/* On scroll */
.logo.scrolled .name {
opacity: 0;
transform: translateX(-2em);
}
.logo.scrolled .glyph {
opacity: 1;
transform: translateX(0);
}
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<div class="logo">
<div class="name">Eric Andre</div>
<div class="glyph">A</div>
</div>

关于jquery - 将 Logo 从一个变形为另一个 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40492996/

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