跟名站學前端之Brian Hoff Design,brianhoff

來源:互聯網
上載者:User

跟名站學前端之Brian Hoff Design,brianhoff
前端開發whqet,csdn,王海慶,whqet,前端開發專家

如果您是資深前端er,經驗豐富、富有創意,也有可能面對新項目一時躊躇;如果您是前端初學者,可能胸中溝壑,無從下手。因此,多多賞析優秀網站,開闊視野、尋求靈感、解析技術顯得很有必要。我們從國內外網頁欣賞站(Awwwards\CSS Winner\Best CSS等)的收錄作品中,選擇一些有代表性的作品進行解析,欣賞、研讀、提高,開始一個全新的系列部落格《跟名站學前端》,希望對大家有所協助。今天開篇立意,來看第一博,我跟名站學前端之Brian Hoff Design。

------------------------------------------------------------

--我參加了部落格之星評選,如果你喜歡我的部落格,求投票,您的支援是我的動力之源,走起!

-----------------------------------------------------------------------------------------

欣賞

Brain Hoff Design是一個面向web和移動平台的互動設計機構(美國),網站介面如下。


解析

明快、鮮亮的動畫是網站的亮點,首頁採用全屏背景、大文字、側欄菜單等各站主流設計,設計簡潔、色彩明快、互動十足是一個不錯的設計。網站裡面用到的一些鮮活的互動動畫是本博文的重點,立體背景按鈕、效果切換的導覽按鈕、書架樣式的圖片響應、箭頭遮罩圖片響應等。

立體背景的按鈕

效果切換的導覽按鈕


書架樣式的圖片響應


箭頭遮罩圖片響應


實現

下面我們分別來實現一下,源碼我放在了codepen,請大家移步。

----------------

----------------------------------------

線上研究點擊這裡,下載收藏點擊這裡。

----------------------------------------

---------------


立體背景按鈕

立體背景的按鈕主要使用css3 3d、css3 transform實現,過程如下,html如下。

<!--立體背景按鈕--><div class="btnContainer">  <div class="btnBg"></div>   <a class="btnBtn" href="#">Read our latest case study</a></div>

css是關鍵,如下代碼所示。

/*立體背景按鈕*/.btnContainer{  position: relative;  width:300px;  height:60px;  margin:20px;}.btnContainer .btnBg{  position: absolute;  background-color: #000;  width:300px;  height:60px;  z-index:-1;  transform: perspective(200px) rotateY(9deg) rotateX(-3deg) translateX(6%) translateZ(-10px) scale(1.05);  transition: all 0.25s ease-in-out;}.btnContainer:hover .btnBg{  transform: perspective(200px) rotateY(-5deg) rotateX(-3deg) translateX(-5%) translateY(2%) translateZ(-20px) scale(1.2);}.btnContainer .btnBtn{  display: inline-block;  text-decoration: none;  font-size: 1.5em;  color: #FFF;  text-align: center;  line-height: 60px;}
轉場效果的導覽功能表

轉場效果的導覽功能表主要由兩個部分的動畫,一個是外圓環,一個是內側動畫。外部的圓環容易實現,改變圓環大小即可。內側的三條線用三個div實現(也可以用:before和:after偽對象實現,簡化問題起見,直接來最簡單的),相應之後中間的邊長,兩側的旋轉。

html如下

<!-- 效果切換的導覽按鈕 --><a class="menuContainer" href="#">    <div class="line"></div>  <div class="line"></div>  <div class="line"></div></a>

css部分實現

/*導航效果切換的導覽按鈕*/.menuContainer{  display: inline-block;  position: relative;  top:0px;  left:0px;  padding:20px 16px;  border: 5px solid #000;  border-radius:100%;  margin:20px;  text-align: center;  transition: all 0.25s ease-in-out;  background-color: #fff;}.menuContainer .line{  background-color: #000;  margin-bottom: 1px;  height: 3px;  width: 20px;  transition: all 0.25s ease-in-out;}.menuContainer:hover{  padding:26px 22px;  top:-8px;  left:-8px;}.menuContainer:hover .line:nth-child(1){  width:13px;  transform:rotateZ(-45deg) translateX(-2px) translateY(-2px);}.menuContainer:hover .line:nth-child(2){  width:24px;}.menuContainer:hover .line:nth-child(3){  width:13px;  transform:rotateZ(45deg) translateX(-2px) translateY(2px);}
書架樣式圖片響應

書架樣式圖片響應的實現過程如下,先看html

<!-- 書架樣式圖片響應 --><a class="bookContainer" href="#"><img class="bookImg" src="http://brianhoffdesign.com/images/mags/netmag.jpg"><div class="bookBtn">View</div></a>

css如下。

/* 書架樣式圖片響應 */.bookContainer{  position: relative;  margin:50px;  width:160px;}.bookContainer:before{  content:"";  width:300px;  height:50px;  border-bottom:8px solid #666;  background-color: #fff;  position: absolute;  left:-70px;  bottom:-5px;}.bookContainer img{  position: relative;  bottom:0;  transition: all 0.25s ease-in-out;}.bookContainer .bookBtn{  width: 100px;  height:30px;  line-height: 30px;  text-align: center;  border:5px solid #666;  position: absolute;  z-index:-10;  left:20px;  top:-30px;  opacity: 0;  transition: all 0.25s ease-in-out;}.bookContainer:hover .bookBtn{  top:30px;  opacity: 1;}.bookContainer:hover img{  bottom:10px;}
箭頭遮罩圖片響應

可以使用-webkit-mask-image,也可以使用svg mask來實現,相對比較複雜,我們改日再來詳細教程。先看使用svg的方案,簡單起見,用圓形先代替。

html檔案,.picContainer作為整個容器的的同時,顯示背景圖片,.bg用於顯示hover之後的半透明遮罩顏色,svg mask顯示清晰的部分。

<div class="picContainer">  <div class="bg"></div>  <svg class="svg" x="0px" y="0px" viewBox="0 0 420 420" >    <defs>      <mask id="mask">        <circle class="circle" cx="-100" cy="200" r="100" fill="white"></circle>      </mask>    </defs>    <image xlink:href="http://brianhoffdesign.com/assets/thumbnail-prizerebel.jpg" mask="url(#mask)" width="420" height="420" x="0" y="0"></image>  </svg></div>

svg的動畫我們用css實現。firefox瀏覽器的運動遮罩尚有問題,待研究。

.picContainer{  margin:100px 80px;  width: 420px;  height: 420px;  position: relative;  background: url(http://brianhoffdesign.com/assets/thumbnail-prizerebel.jpg) no-repeat;}.picContainer .svg{  width:420px;  height: 420px;  position: absolute;}.picContainer .circle{  transform: translate(-100px);  opacity: 0;  transition: all .5s ease-in-out;}.picContainer:hover .circle{  transform: translate(100px);  opacity: 1;}.picContainer .bg{  width: 420px;  height: 420px;  background-color: #fdfdfd;  position: absolute;  transition: all .5s ease-in-out;  opacity: 0;}.picContainer:hover .bg{  opacity: 0.9;}

感謝您耐心讀完,如果對您有協助,請支援我!

----------------------------------------------------------

前端開發whqet,關注web前端開發,分享相關資源,歡迎點贊,歡迎拍磚。
---------------------------------------------------------------------------------------------------------

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.