跟名站學前端之Trippeo,名站學之Trippeo
前端開發whqet,csdn,王海慶,whqet,前端開發專家
如果您是資深前端er,經驗豐富、富有創意,也有可能面對新項目一時躊躇;如果您是前端初學者,可能胸中溝壑,無從下手。多多賞析優秀網站,開闊視野、尋求靈感、解析技術,很有必要。我們從國內外網頁欣賞站(Awwwards\CSS Winner\Best CSS等)的收錄作品中,選擇一些有代表性的作品進行解析,欣賞、研讀、提高,開始一個全新的系列部落格《跟名站學前端》,希望對大家有所協助。
今天早上閑逛的時候發現了《Trippeo》-一個管理商業旅行軟體產品的官方網站,網站簡潔而又大方,值得我們學習,我們重點研讀它的文字遮罩連結效果。
欣賞
《Trippeo》網站簡潔而又大方,值得我們學習,介面效果如所示。
首頁的載入效果很酷,數字動畫代表載入過程,載入完成之後可以向下滾動。
我們重點研讀它的文字連結效果,使用webkit瀏覽器獲得最佳效果,如所示。
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ==== 文字遮罩動畫==== ==全屏預覽== ==線上編輯== ==下載收藏== -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ==== svg圓形動畫導航(高手作品,非原創)==== ==全屏預覽== ==線上編輯== ==下載收藏== --------------------------------------------------------------------------------------------------------------------------------------------------------------------------原理解析
使用:before偽對象實現變色之後的字、底線、描邊字等;
對:before偽對象進行clip裁切;
利用transition實現動畫。
實現過程
html
<a class="gra gra1" href="#" data-content="漸層效果">漸層效果</a>
css,首先設定連結,去底線、設定字型、大小、顏色、位置;然後設定:before對象,大小、位置、顏色、content、transition等,設定hover前後的clip屬性。
.gra{ text-decoration: none; font-size:3em; font-family:'simhei'; color: #a5cdff; position: relative; float: left; margin: 20px;}.gra::before{ left: 0; position: absolute; top: 0; content: attr(data-content); color: #4b58cc; display: inline-block; zoom: 1; transition: clip .4s cubic-bezier(0.645,.045,.355,1); width: 100%;}.gra:hover::before{ clip: rect(0,240px,50px,0);}.gra1::before{ clip: rect(0,0,50px,0);}
然後變體,擴充出一些其他效果。
<a class="gra gra1" href="#" data-content="漸層效果">漸層效果</a><a class="gra gra2" href="#" data-content="漸層效果">漸層效果</a><a class="gra gra3" href="#" data-content="漸層效果">漸層效果</a><a class="gra gra4" href="#" data-content="漸層效果">漸層效果</a><a class="gra gra5" href="#" data-content="漸層效果">漸層效果</a><a class="gra gra6" href="#" data-content="漸層效果">漸層效果</a><a class="gra graphic" href="#" data-content="描邊字效果">描邊字效果</a><a class="gra underline" href="#" data-content="底線效果">底線效果</a>
.gra{ text-decoration: none; font-size:3em; font-family:'simhei'; color: #a5cdff; position: relative; float: left; margin: 20px;}.gra::before{ left: 0; position: absolute; top: 0; content: attr(data-content); color: #4b58cc; display: inline-block; zoom: 1; transition: clip .4s cubic-bezier(0.645,.045,.355,1); width: 100%;}.gra:hover::before{ clip: rect(0,240px,50px,0);}/*漸層字效果*/.gra1::before{ clip: rect(0,0,50px,0);}.gra2::before{ clip: rect(0,220px,0,0);}.gra3::before{ clip: rect(0,220px,50px,220px);}.gra4::before{ clip: rect(50px,220px,50px,0);}.gra5::before{ clip: rect(25px,220px,50px,0);}.gra6::before{ clip: rect(0,100px,50px,0);}/*描邊字效果*/.graphic::before{ -webkit-text-fill-color: transparent; -webkit-text-stroke: 1px #00f; background-size: cover; clip: rect(0,0,50px,0);}.graphic:hover::before{ clip: rect(0,240px,50px,0);}/*底線效果*/.underline::before{ top:50px; content:""; height:2px; clip: rect(0,0,50px,0); background: linear-gradient(left , rgb(37, 208, 243) 11% , rgb(15, 42, 145) 93%); background: -o-linear-gradient(left , rgb(37, 208, 243) 11% , rgb(15, 42, 145) 93%); background: -ms-linear-gradient(left , rgb(37, 208, 243) 11% , rgb(15, 42, 145) 93%); background: -moz-linear-gradient(left , rgb(37, 208, 243) 11% , rgb(15, 42, 145) 93%); background: -webkit-linear-gradient(left , rgb(37, 208, 243) 11% , rgb(15, 42, 145) 93%); }.underline:hover::before{ clip: rect(0,240px,50px,0);}
----------------------------------------------------------
前端開發whqet,關注前端開發,分享相關資源,歡迎點贊,歡迎拍磚。
---------------------------------------------------------------------------------------------------------