我有一些div
标签在页面上,一旦他们在一个视口,我希望他们以某种方式动画。我已经在'视口'部分使用了waypoint.js
,所以现在我被卡住了动画。下划线标头CSS动画
基本上,我希望在任何时候都在所有h1标签上留下灰色下划线。一旦他们看到了,我想要一条黑线从右到左在这条灰线的上方运行,然后几乎离开现场,停在灰线约25%处。
为了演示它,我已经改变了效果在hover
上工作,正如你所看到的,当它穿过灰色线条时我已经有了部分,但是当它应该离开时我会卡住部分现场(几乎离开现场 - 在灰线的25%停止):
HTML:
<div class="section-header">
<span>Hello</span>
</div>
CSS:
.section-header {
text-transform: uppercase;
font-weight: 700;
font-size: 2em;
letter-spacing: 5px;
position: relative;
text-align: center;
> span {
display: inline-block;
position: relative;
border-bottom: 1px solid #ccc;
&:before {
content: "";
position: absolute;
width: 0;
height: 1px;
bottom: -1px;
right: 0;
background-color: #000;
visibility: hidden;
-webkit-transition: all 0.9s ease-in-out 0s;
transition: all 0.9s ease-in-out 0s;
}
&:hover {
&:before {
visibility: visible;
width: 100%;
}
}
}
}
http://codepen.io/anon/pen/RWoxBv
这可能在CSS中完成吗?或者我应该使用JavaScript吗?
为了进一步展示动画,想象这是黑线:(!= 25%可见)
- (starts from right hand side and goes to left)
--
---
----
-----
------
-------
--------
---------
----------
-----------
------------ (point when it covers the grey line and starts to 'leave the scene')
-----------
----------
---------
--------
-------
------
-----
----
--- (stopping there)
* *停止......什么后*停止*? –
请在问题本身发布相关代码。问题应该是独立的,我们不应该离开现场去检查你的问题 – charlietfl
*“离开现场......几乎离开现场”*?你可以请更具体吗? –