css3 data-attribute屬性打造漂亮的按鈕,css3data-attribute

來源:互聯網
上載者:User

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;        }



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.