我有一些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
*「離開現場......幾乎離開現場」*?你可以請更具體嗎? –