CSS3讓登陸面板3D旋轉(zhuǎn)起來
發(fā)布時間:2016-05-03 16:27:07 作者:佚名
我要評論

點(diǎn)擊登陸面板會發(fā)生360度旋轉(zhuǎn),并顯示信息,真正使用CSS3讓登陸面板3D旋轉(zhuǎn)起來,如何實(shí)現(xiàn)登陸面板3D旋轉(zhuǎn),感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了利用CSS3實(shí)現(xiàn)登陸面板3D旋轉(zhuǎn)起來的具體代碼,供大家參考,具體內(nèi)容如下
效果圖:
點(diǎn)擊登陸,登陸面板會發(fā)生360度旋轉(zhuǎn),并顯示信息。
旋轉(zhuǎn)結(jié)束:
示例代碼:
XML/HTML Code復(fù)制內(nèi)容到剪貼板
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>登陸面板旋轉(zhuǎn)</title>
- <style>
- body {
- font-family: "Microsoft YaHei", "微軟雅黑";
- }
- .container {
- /*創(chuàng)建3D場景*/
- -webkit-perspective: 800;
- -webkit-perspective-origin: 50% 50%;
- -webkit-transform-style: -webkit-preserve-3d; /*告訴瀏覽器以下transform操作是在3D場景下進(jìn)行的*/
- }
- #login-panel {
- /*-webkit-transform: rotateX(45deg);*/
- }
- .login {
- width: 500px;
- height: 400px;
- margin: 100px auto;
- text-align: center;
- border: 1px solid #ABCDEF;
- border-radius: 10px;
- box-shadow: 0 0 3px 3px #ABCDEF;
- }
- .login h1 {
- margin: 50px 0;
- }
- .login-row span {
- font-size: 18px;
- }
- .login-row input {
- height: 25px;
- line-height: 25px;
- padding: 0 10px;
- margin: 10px 0;
- }
- .btn {
- outline: none;
- background-color: aliceblue;
- cursor: pointer;
- width: 90px;
- height: 40px;
- border: 1px solid #DDD;
- border-radius: 5px;
- margin: 30px 20px;
- font-size: 16px;
- transition: background-color 0.5s;
- -webkit-transition: background-color 0.5s;
- -moz-transition: background-color 0.5s;
- -o-transition: background-color 0.5s;
- }
- .btn:hover {
- background-color: antiquewhite;
- }
- .login-success {
- font-size: 20px;
- padding: 50px;
- }
- </style>
- <script>
- var loginBtn, regiBtn;
- window.onload = function() {
- loginBtn = document.getElementById("login");
- loginBtn.onclick = rotate;
- regiBtn = document.getElementById("regi");
- regiBtn.onclick = rotate;
- };
- function rotate() {
- var x = 0;
- var panel = document.getElementById("login-panel");
- panel.style.transform = "rotateX(0deg)";
- panel.style.webkitTransform = "rotateX(0deg)";
- var flag = true;
- var timer = setInterval(function() {
- if(Math.round(x) >= 90 && flag) {
- panel.innerHTML = "<p class='login-success'>登陸成功</p>";
- flag = false;
- }
- if(Math.round(x) >= 358) {
- panel.style.transform = "rotateX(360deg)";
- panel.style.webkitTransform = "rotateX(360deg)";
- clearInterval(timer);
- return false;
- } else {
- x += 2 + (360 - x) / 60;
- panel.style.transform = "rotateX(" + x + "deg)";
- panel.style.webkitTransform = "rotateX(" + x + "deg)";
- }
- }, 25);
- }
- </script>
- </head>
- <body>
- <div class="container">
- <div class="login" id="login-panel">
- <h1>登陸</h1>
- <div class="login-row">
- <label for="username"><span>賬號:</span></label>
- <input type="text" id="username" name="username">
- </div>
- <div class="login-row">
- <label for="password"><span>密碼:</span></label>
- <input type="password" id="password" name="password">
- </div>
- <div class="login-row">
- <button id="login" class="btn" type="button">登陸</button>
- <button id="regi" class="btn" type="button">注冊</button>
- </div>
- </div>
- </div>
- </body>
- </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。
相關(guān)文章
CSS3 3D旋轉(zhuǎn)rotate效果實(shí)例介紹
這篇文章主要為大家詳細(xì)介紹了CSS3 3D旋轉(zhuǎn)rotate效果實(shí)例,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-05-03- 這篇文章主要介紹了CSS3近階段篇之酷炫的3D旋轉(zhuǎn)透視 的相關(guān)資料,需要的朋友可以參考下2016-04-28
CSS3實(shí)現(xiàn)的一款迷人3D木塊旋轉(zhuǎn)動畫
一款迷人的HTML5+CSS3實(shí)現(xiàn)的3D旋轉(zhuǎn)動畫,這款3D動畫的主角是一根根小木條2014-05-06CSS3實(shí)現(xiàn)酷炫的3D旋轉(zhuǎn)透視效果
這篇文章主要介紹了CSS3實(shí)現(xiàn)酷炫的3D旋轉(zhuǎn)透視效果,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-11-21