CSS實現3D按鈕效果

來源:互聯網
上載者:User
這次給大家帶來CSS實現3D按鈕效果,CSS實現3D按鈕效果的注意事項有哪些,下面就是實戰案例,一起來看一下。

css巧妙利用了box-shadow來實現3D物體的立體感,當按鈕按下的時候再去修改box-shadow和top值。

讓人感覺有一種按鈕被按下的感覺。css代碼非常少,如下所示

a.css-3d-btn{ position: relative; color: rgba(255, 255, 255, 1); text-decoration: none; background-color: rgba(219, 87, 51, 1); font-family: "Microsoft YaHei", 微軟雅黑, 宋體; font-weight: 700; font-size: 3em; display: block; padding: 4px; border-radius: 8px; /* let's use box shadows to make the button look more 3-dimensional */ box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7); margin: 100px auto; width: 160px; text-align: center; -webkit-transition: all .1s ease; -moz-transition: all .1s ease; transition: all .1s ease;}/* now if we make the box shadows smaller when the button is clicked, it'll look like the button has been "pushed" */a.css-3d-btn:active{ box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9); position: relative; top: 6px;}

效果如下:

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

用transparent做出三角形

HTML5+CSS3載入進度條與下載進度條實現

相關文章

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.