原創|使用教程|編輯:龔雪|2014-11-25 10:19:00.000|閱讀 1344 次
概述:Ghost Button(虛擬按鈕)是網頁設計中一個非常實用的按鈕樣式,特別是圖片背景中,有出色的效果。今天我們一起來研究Ghost Button的各種效果的制作方法,并對Ghost Button在web設計中的發展趨勢進行分析。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
【年終大促 巔峰盛"慧" 】促銷火熱進行中 iPhone 6 Plus、 iPhone 6、iPad Air等你拿 點我查看
慧都聯合葡萄城產品年終大惠,第二套起,買一送一!11月17日-12月31日,機會不容錯過!點我查看
FastReport VCL 5新版發布會,2014-12-9 15:00網絡直播,免費參加?,參加者買FastReport旗下所有產品<6折>
1、圖片背景:Ghost buttons使用優秀的圖片背景,圖片上 的按鈕不會影響用戶觀看圖片。可以給用戶一個非常幫的可視化效果。
2、白色是流行的Ghost Button顏色:Ghost buttons可以設置任何你想要的顏色,你可以根據自己的圖片選擇相應顏色,不過白色比較流行。
3、CSS轉換:我們可以使用CSS增強Ghost buttons的效果。
下面我們就來開啟Ghost Button設計之旅。
效果圖:
步驟一:HTML
我們使用HTML<a>元素來展現
<a class="ghost-button" href="#">Ghost button text</a>
步驟二:CSS
我們來體驗下Ghost button的8中變換:
.ghost-button { display: inline-block; width: 200px; padding: 8px; color: #fff; border: 1px solid #fff; text-align: center; outline: none; text-decoration: none; }
這些都是基本的CSS屬性,制作出基本Ghost Button效果。如果需要變化,我們只需要修改屬性或添加屬性。
我們這里是一個懸停效果,用戶鼠標懸停或激活Ghost Button,有指示出現。我們使用偽類: :hover and :active
.ghost-button:hover, .ghost-button:active { background-color: #fff; color: #000; }
添加border-radius可以為ghost buttons添加圓角效果:
.ghost-button-rounded-corners { display: inline-block; width: 200px; padding: 8px; color: #fff; border: 1px solid #fff; border-radius: 5px; text-align: center; outline: none; text-decoration: none; } .ghost-button-rounded-corners:hover, .ghost-button-rounded-corners:active { background-color: #fff; color: #000; }
使用CSS transition屬性來實現
.ghost-button-transition { display: inline-block; width: 200px; padding: 8px; color: #fff; border: 2px solid #fff; text-align: center; outline: none; text-decoration: none; transition: background-color 0.2s ease-out, color 0.2s ease-out; } .ghost-button-transition:hover, .ghost-button-transition:active { background-color: #fff; color: #000; transition: background-color 0.3s ease-in, color 0.3s ease-in; }
使用border-size,將其設置為自己想要的大小:
.ghost-button-thick-border { display: inline-block; width: 200px; font-weight: bold; padding: 8px; color: #fff; border: 3px solid #fff; text-align: center; outline: none; text-decoration: none; transition: background-color 0.2s ease-out, color 0.2s ease-out; } .ghost-button-thick-border:hover, .ghost-button-thick-border:active { background-color: #fff; color: #000; transition: background-color 0.3s ease-in, color 0.3s ease-in; }
使用rgba()功能,下面我們要實現背景、邊界為白色,40%透明,我們可以如下設置:
rgba(255, 255, 255, 0.4)
rgba()功能是CSS特性,不一定所有瀏覽器都支持,所以,我們可以使用十六進制符號以防萬
一。
.ghost-button-semi-transparent { display: inline-block; width: 200px; padding: 8px; color: #fff; border: 2px solid #fff; text-align: center; outline: none; text-decoration: none; transition: background-color 0.2s ease-out, border-color 0.2s ease-out; } .ghost-button-semi-transparent:hover, .ghost-button-semi-transparent:active { background-color: #fff; /* fallback */ background-color: rgba(255, 255, 255, 0.4); border-color: #fff; /* fallback */ border-color: rgba(255, 255, 255, 0.4); transition: background-color 0.3s ease-in, border-color 0.3s ease-in; }
修改CSS transition屬性實現。
.ghost-button-border-color { display: inline-block; width: 200px; padding: 8px; color: #fff; border: 2px solid #fff; text-align: center; outline: none; text-decoration: none; transition: border-color 0.3s ease-out, color 0.3s ease-out; } .ghost-button-border-color:hover, .ghost-button-border-color:active { color: #66d8ed; border-color: #66d8ed; transition: border-color 0.4s ease-in, color 0.4s ease-in; }
修改CSS transition屬性,并改變background-color屬性。
.ghost-button-full-color { display: inline-block; width: 200px; padding: 8px; color: #fff; background-color: transparent; border: 2px solid #fff; text-align: center; outline: none; text-decoration: none; transition: color 0.3s ease-out, background-color 0.3s ease-out, border-color 0.3s ease-out; } .ghost-button-full-color:hover, .ghost-button-full-color:active { background-color: #9363c4; border-color: #9363c4; color: #fff; transition: color 0.3s ease-in, background-color 0.3s ease-in, border-color 0.3s ease-in; }
.ghost-button-size-transition { display: inline-block; width: 200px; height: 25px; line-height: 25px; margin: 0 auto; padding: 8px; color: #fff; border: 2px solid #fff; text-align: center; outline: none; text-decoration: none; transition: width 0.3s ease-out, height 0.3s ease-out, line-height 0.3s ease-out; } .ghost-button-size-transition:hover, .ghost-button-size-transition:active { width: 220px; height: 45px; line-height: 45px; transition: width 0.1s ease-in, height 0.1s ease-in, line-height 0.1s ease-in; }
英文原文:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網