css3 data-attribute屬性打造漂亮的按鈕,css3data-attribute
之前介紹了幾款css3實現的按鈕,今天為網友來款比較新鮮的,用css3的data-attribute屬性開發按鈕,當滑鼠經過顯示按鈕的詳細資料。而且實現過程很簡單,幾行代碼就搞定。大家試一試吧。如:
線上預覽 源碼下載
不錯吧,貼上實現代碼:
html代碼:
<button data-hover="愛編程(w2bc.com)收集編程資料,web前端案例"> 愛編程</button>
css代碼:
button { background: #db701f; border: solid 7px #000; padding: 20px; box-shadow: inset 0 0 6px #824212; text-transform: uppercase; font-weight: bold; font-family: "Tahoma" , sans-serif; text-shadow: 1px 1px 3px #824212; color: #fff; position: relative; width: 300px; font-size:16px; } button:hover { background: green; } button:hover:before { /* ------- THIS IS THE MAGIC ----------------*/ content: attr(data-hover); /* ------------------------------------------*/ display: block; background: #000; position: absolute; top: 100%; left: -7px; right: -7px; padding: 15px; } button:hover:after { content: ""; position: absolute; display: block; width: 0; height: 0; border: solid 10px transparent; border-bottom-color: #000; bottom: 0; left: 50%; margin-left: -10px; z-index: 2; } .note { margin-top: 100px; display: block; }