標籤:跟名站學前端 web前端開發 前端開發
前端開發whqet,csdn,王海慶,whqet,前端開發專家
如果您是資深前端er,經驗豐富、富有創意,也有可能面對新項目一時躊躇;如果您是前端初學者,可能胸中溝壑,無從下手。多多賞析優秀網站,開闊視野、尋求靈感、解析技術,很有必要。我們從國內外網頁欣賞站(Awwwards\CSS Winner\Best CSS等)的收錄作品中,選擇一些有代表性的作品進行解析,欣賞、研讀、提高,開始一個全新的系列部落格《跟名站學前端》,希望對大家有所協助。
今天來看某百科網站的年度總結,互動體驗超贊!
------------------------------------------------------------
--我參加了部落格之星評選,如果你喜歡我的部落格,求投票,您的支援是我的動力之源,走起!
-----------------------------------------------------------------------------------------------------------------
欣賞
某百科網站的年度總結,互動體驗超贊!網站介面如下。
請大家移步欣賞之後,5分鐘之後回來繼續。系列文章的目的有兩個,一是開拓視野、激發靈感、積蓄創意,其次才是擷取技術的提高,所以大家不可偷懶。
解析
沿襲某度簡潔、大方的一貫風格,使用一些圓形、三角形元素裝點頁面,整個頁面顯得非常親民。同時互動體驗良好。
我們來重點三角形映像菜單的實現。
三角形映像菜單實現
源碼我放在了codepen,請大家移步。
----------------
----------------------------------------
全屏預覽點擊這裡,線上研究點擊這裡,下載收藏點擊這裡。
----------------------------------------
---------------
在該效果中,用一個圖片來表示做背景顯示映像,然後用空的div作透明按鈕(類似於flash裡面的透明按鈕)。hove之後的顯示的灰色用svg畫出來。
html部分如下。
<div class="subRanking"> <div class="detail detail-up detail-0"> <div class="detail_title"> <a style="font-size: 16px" href="http://baike.baidu.com/subview/38681/5279942.htm" target="_blank">鄧超</a> <a style="font-size: 16px" href="http://baike.baidu.com/view/16973.htm" target="_blank">孫儷</a> </div> </div> <div class="detail detail-down detail-1"> <div class="detail_title"> <a style="font-size: 16px" href="http://baike.baidu.com/view/3286.htm" target="_blank">謝霆鋒</a> <a style="font-size: 16px" href="http://baike.baidu.com/subview/3208/5954154.htm" target="_blank">王菲</a> </div> </div> <div class="detail detail-down detail-2"> <div class="detail_title"> <a style="font-size: 16px" href="http://baike.baidu.com/view/8234763.htm" target="_blank">陳思誠</a> <a style="font-size: 16px" href="http://baike.baidu.com/view/1614105.htm" target="_blank">佟麗婭</a> </div> </div> <div class="detail detail-down detail-3"> <div class="detail_title"> <a style="font-size: 16px" href="http://baike.baidu.com/subview/48513/11093165.htm" target="_blank">皮特</a> <a style="font-size: 16px" href="http://baike.baidu.com/view/68401.htm" target="_blank">朱莉</a> </div> </div> <div class="detail detail-up detail-4"> <div class="detail_title"> <a style="font-size: 16px" href="http://baike.baidu.com/view/15398.htm" target="_blank">汪峰</a> <a style="font-size: 16px" href="http://baike.baidu.com/view/2793.htm" target="_blank">章子怡</a> </div> </div> <div class="detail detail-up detail-5"> <div class="detail_title"> <a style="font-size: 16px" href="http://baike.baidu.com/view/2149822.htm" target="_blank">趙又廷</a> <a style="font-size: 16px" href="http://baike.baidu.com/view/10531.htm" target="_blank">高圓圓</a> </div> </div> <div class="detail detail-up detail-6"> <div class="detail_title"><a style="font-size: 16px" href="http://baike.baidu.com/view/172294.htm" target="_blank">劉愷威</a> <a style="font-size: 16px" href="http://baike.baidu.com/view/3871.htm" target="_blank">楊冪</a> </div> </div> <div class="detail detail-up detail-7"> <div class="detail_title"> <a style="font-size: 16px" href="http://baike.baidu.com/subview/13909/5530564.htm" target="_blank">黃曉明</a> <a style="font-size: 16px" href="http://baike.baidu.com/view/1513794.htm" target="_blank">Angelababy</a> </div> </div> <div class="detail detail-down detail-8"> <div class="detail_title"> <a style="font-size: 16px" href="http://baike.baidu.com/view/2632.htm" target="_blank">周杰倫</a> <a style="font-size: 16px" href="http://baike.baidu.com/view/2200222.htm" target="_blank">昆淩</a> </div> </div> <div class="detail detail-down detail-9"> <div class="detail_title"> <a style="font-size: 16px" href="http://baike.baidu.com/view/6231131.htm" target="_blank">高聖遠</a> <a style="font-size: 16px" href="http://baike.baidu.com/subview/6095/5885891.htm" target="_blank">周迅</a> </div> </div> <svg width="100%" height="100%" class="svg"> <path d="M6,0 L310,0,158,152" class="shape"></path> <path d="M324,3 L476,155,172,155" class="shape"></path> <path d="M338,0 L642,0,490,152" class="shape"></path> <path d="M656,3 L808,155,504,155" class="shape"></path> <path d="M670,0 L974,0,822,152" class="shape"></path> <path d="M324,318 L476,165,172,165" class="shape"></path> <path d="M656,318 L808,165,504,165" class="shape"></path> <path d="M490,166 L649,325,490,484,331,325" class="shape"></path> <path d="M324,333 L476,485,172,485" class="shape"></path> <path d="M656,333 L808,485,504,485" class="shape"></path> </svg></div>
css主要實現布局,同時考慮hover之後的元素表現。
.subRanking{ width:980px; height: 485px; margin:30px auto; background:url(http://baike.bdimg.com/cms/static/moments-2014/subRankings/result/entertain-2.png) no-repeat 100% 100%;}.detail {position: absolute;z-index: 1;width: 90px;height: 90px;text-align: center;color: #fff;cursor: default;transition:all .2s linear; cursor:pointer;}.detail-0 {left: 113px;top: 7px}.detail-2 {left: 445px;top: 7px}.detail-4 {left: 777px;top: 7px}.detail-1 {left: 279px;top: 60px}.detail-3 {left: 611px;top: 60px}.detail-5 {left: 279px;top: 171px}.detail-6 {left: 611px;top: 171px}.detail-7 {left:445px;top:285px}.detail-8 {left: 279px;top: 390px}.detail-9 {left: 611px;top: 390px}.detail .detail_title {position: relative;margin: 3px 0 5px;height: 24px;line-height: 24px;font-size: 18px;opacity: 0; transition:all .1s linear;}.detail .detail_title a {color: #fff;text-decoration: none;border-bottom: 1px solid #fff}.detail-up .detail_title {left: -35px; top:50px;width: 200px}.detail-down .detail_title {left: -35px; bottom:-50px; width: 200px;}.svg {position: relative;z-index: 0}.svg .shape { opacity:0.1;transition:opacity .1s ease-in;}.show {opacity: 1;}.show .detail_title {opacity: 1;}
js主要實現hover響應,hover之後顯示detail_title元素,顯示對應的svg元素,我們使用jquery類庫簡化書寫。
$(‘.detail‘).hover( function(){ $(this).addClass(‘show‘); $(‘.shape‘).eq($(this).index()).css(‘opacity‘,‘.6‘); }, function(){ $(this).removeClass(‘show‘); $(‘.shape‘).eq($(this).index()).css(‘opacity‘,‘.1‘); });
完工!
感謝您耐心讀完,如果對您有協助,請支援我
----------------------------------------------------------
前端開發whqet,關注web前端開發,分享相關資源,歡迎點贊,歡迎拍磚。
---------------------------------------------------------------------------------------------------------
跟名站學前端之某百科網站