gpt4 book ai didi

CSS 爱!鼠标悬停在 blockquote 中的动画背景有效,但鼠标移开时无效

转载 作者:行者123 更新时间:2023-11-28 09:44:35 27 4
gpt4 key购买 nike

我花了几个小时彻底修改标准 <blockquote>标记,现在我停留在最后一步,即动画。我已经尝试了几乎所有的东西,但可以让它正常工作。如果有人可以在这里帮助我,我将不胜感激。

理想情况下,我希望 Twitter 小鸟移动并淡入淡出:

LEFTCENTER(在向中心移动时淡入 - 在鼠标悬停时)和
CENTERRIGHT(向右移动时淡出 - 鼠标移开)

我让小鸟在鼠标悬停时从左侧移动到中心,但我无法让它在鼠标移开时从中心移动到右侧。

请注意这个<blockquote>是用伪类和元素定制的,看起来像这样。

<blockquote>
<a href="#">Text link here</a>
</blockquote>

我为链接使用了 1 类,只是为了扩大可点击区域。如果您知道不涉及这个老把戏的方法,请告诉我。

请看我的作品。我们非常欢迎任何建议或代码改进。

FIDDLE - https://jsfiddle.net/7kr7en1m

最佳答案

我用了this answer帮助解决这个问题。

关键是为 margin-left 和 margin-left 设置动画。它是这样工作的:

  1. 鸟从 blockquote 的右边开始
  2. 悬停时,通过将 margin-left 设置为 0,小鸟移动到 blockquote 的左侧,没有任何动画,然后开始 left 属性开始动画。
  3. 悬停后,小鸟向右移动,因为 margin-left 动画已重新应用。

a {
text-decoration: none;
}

a:link {
color: #f00;
}

a:visited {
color: #f00;
}

a:hover {
color: rgba(0, 0, 0, 0);
}

blockquote {
position: relative;
font-weight: 900;
font-size: 18px;
line-height: 22px;
text-align: left;
padding: 10px 35px 10px;
margin: 0 15px;
border: solid 1px rgb(220, 220, 220);
border-radius: 10px;
position: relative;
background-color: white;
box-shadow: 5px 5px 20px #e9edef;
width: 20%;
min-width: 200px;
float: right;
overflow: hidden;
}

blockquote:hover {

}

a:after {
content: '';
position: absolute;
width: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
left: -90%;
margin-left: 200%;
transition: left 300ms linear, margin-left 300ms ease-out;
color: #009fff;
cursor: pointer;
background-image: url('http://image.prntscr.com/image/39b3926093f442c095554fb6a147ef01.png');
background-repeat: no-repeat;
background-position: center;
background-size: contain;
/* transition: background-image 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-o-transition: all 0.5s ease; */
}

a:before {
content: '';
transition: background-color 300ms ease;
}

a:hover:before {
position: absolute;
width: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-position: center;
background-size: contain;
background-color: #009fff;
border: solid 1px #009fff;
}

a:hover:after {
transition: left 300ms ease-out;
margin-left: 0;
left: 0;
}
<h3>
What is Lorem Ipsum?
</h3>

<blockquote>
<a href="#" class="qoute-to-tweet">Animated Lorem Ipsum dummy text that is used in this quote is ready to be tweeted with one click</a>
</blockquote>

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

关于CSS 爱!鼠标悬停在 blockquote 中的动画背景有效,但鼠标移开时无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40825616/

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